无法从<path>找到模块'typescript',但是tsc -v logs

时间:2017-11-09 17:58:19

标签: macos angular typescript node-modules nrwl

我使用project nrwl/nx,我在家用电脑(Windows)上启动了工作区(morningharwood)和app(组合)。在移动中,我现在克隆了回购,yarn install deps并试图在我的Mac上运行。不幸的是,在运行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", 
}

1 个答案:

答案 0 :(得分:1)

这个问题已由问题109解决 https://github.com/nrwl/nx/issues/109

以下是你如何纠正它:

  

问题是因为.angular-cli.json中的root属性设置为   &#34; root&#34;:&#34; apps \ portfolio \ src&#34;,如果您将其更改为   apps / portfolio / src,它会工作。我会解决它。

应在将来的nrwl版本中予以纠正。