无法从 <Path> 中找到模块 'typescript',但 tsc -v 记录

Cannot find module 'typescript' from <Path> but tsc -v logs

我有一个 project using nrwl/nx,我在家用电脑 (windows) 上启动了工作区 (morningharwood) 和一个应用程序 (portfolio)。在移动中,我现在克隆了存储库,yarn install 部门并尝试 运行 在我的 mac 上。不幸的是,当 运行ning node_modules/.bin/ng serve --app=portfolio 我得到一个错误 Cannot find module 'typescript' from '/Users/m/projects' 在本地和全局我安装了打字稿:

问题:为什么我的项目找不到打字稿;我如何 运行 我的项目在我的 mac 上?

m@mac: ~/projects/ on feature/prerender [?]
$ tsc -v
Version 2.6.1

m@mac: ~/projects/morningharwood/platform on feature/prerender [?]
$ node_modules/.bin/ng serve --app=portfolio

Cannot find module 'typescript' from '/Users/m/projects'
Error: Cannot find module 'typescript' from '/Users/m/projects'
    at Function.module.exports [as sync] (/Users/m/projects/morningharwood/platform/node_modules/resolve/lib/sync.js:40:15)
    at Object.requireProjectModule (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/utilities/require-project-module.js:6:28)
    at Object.readTsconfig (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/utilities/read-tsconfig.js:6:48)
    at new NgCliWebpackConfig (/Users/mharwood/projects/morningharwood/platform/node_modules/@angular/cli/models/webpack-config.js:19:42)
    at Class.run (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/tasks/serve.js:71:29)
    at check_port_1.checkPort.then.port (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/commands/serve.js:123:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
m@mac: ~/projects/morningharwood/platform on feature/prerender [?]

package.json

"devDependencies": {
  "ts-node": "^3.3.0",
  "tsconfig-paths": "^2.3.0",
  "tslint": "~5.3.2",
  "typescript": "2.4.2", 
}

这个问题已经在issue 109解决了 https://github.com/nrwl/nx/issues/109

纠正方法如下:

The issue is because the root property in .angular-cli.json is set to "root": "apps\portfolio\src", if you change it to apps/portfolio/src, it will work. I'll fix it.

应该在 nrwl 的未来版本中更正。