John Abraham
John Abraham

Reputation: 18831

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

I have a project using nrwl/nx and I started the workspace(morningharwood) and an app(portfolio) on my home computer (windows). On the move, I've now cloned the repo, yarn install the deps and tried to run on my mac. Unfortunately, when running node_modules/.bin/ng serve --app=portfolio I get an error that Cannot find module 'typescript' from '/Users/m/projects' locally and globally i have typescript install:

Question: Why cant my project find typescript; How can I run my project on my 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", 
}

Upvotes: 0

Views: 2224

Answers (1)

John Abraham
John Abraham

Reputation: 18831

This issue has be solved by issue 109 https://github.com/nrwl/nx/issues/109

Here's how you correct it:

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.

Should be corrected in the future releases of nrwl.

Upvotes: 1

Related Questions