Cannot find module '@angular/compiler-cli' when running ng serve
Error: Cannot find module '@angular/compiler-cli'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.
@angular/cli: 1.0.0-beta.31 node - v7.5.0 npm - 4.1.2
Please help when running ng serve, the angular cli not found error comes up.
Can you provide your package.json?
Please also run and provide the output of npm ls @angular/compiler-cli from within the project directory.
Also, in the future, please use the provided issue template to allow assistance to be rendered in a more timely manner.
OS?
macOS Sierra
Versions.
@angular/cli: 1.0.0-beta.31 node: 6.9.5 os: darwin x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/compiler-cli: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/material: 2.0.0-beta.2 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/router: 3.4.7
Repro steps.
Update NPM and new install of npm and angular cli on new MacBook Pro with macOS Sierra...
The log given by the failure.
ng serve
Cannot find module '@angular/compiler-cli'
Error: Cannot find module '@angular/compiler-cli'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.
Mention any other details that might be useful.
package.json:
{ "name": "myapp", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "ng": "ng", "start": "ng serve", "lint": "tslint "src/**/*.ts"", "test": "ng test", "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "^2.4.7", "@angular/compiler": "^2.4.7", "@angular/compiler-cli": "^2.4.7", "@angular/core": "^2.4.7", "@angular/forms": "^2.4.7", "@angular/http": "^2.4.7", "@angular/material": "^2.0.0-beta.2", "@angular/platform-browser": "^2.4.7", "@angular/platform-browser-dynamic": "^2.4.7", "@angular/router": "^3.4.7", "@types/node": "^6.0.63", "angularfire2": "^2.0.0-beta.7-pre", "codelyzer": "^2.0.0", "core-js": "^2.4.1", "firebase": "^3.6.9", "hammerjs": "^2.0.8", "rxjs": "^5.1.1", "ts-helpers": "^1.1.1", "tslint": "^4.4.2", "zone.js": "^0.7.7" }, "devDependencies": { "@angular/compiler-cli": "^2.3.1", "@types/jasmine": "2.5.38", "@types/node": "^6.0.42", "angular-cli": "1.0.0-beta.24", "codelyzer": "~2.0.0-beta.1", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "~4.0.13", "ts-node": "1.2.1", "tslint": "^4.0.2", "typescript": "~2.0.3" } }
npm ls @angular/compiler-cli:
[email protected] /Users/xx/xx/xx/xx/xx └── @angular/[email protected]
this happens to me too, just after runing: $ npm remove -g angulat-cli $ npm install -g @angular/cli
Remove angular-cli from your package.json and replace it with @angular/cli
$ npm uninstall angular-cli
$ npm install @angular/cli --save-dev
That seemed to work for me.
Getting same error "ng serve". Working on happy-shopper github project.
Same error even after changing to @angular/cli
I don't have @angular/compiler-cli as a dependency. Trying now after adding it.
Now getting TypeError: patterns.map is not a function
got it, to upgrade from "angular-cli" to "@angular/cli" run this:
update angular-cli to the latest version
$ npm remove -g angular-cli $ npm install -g @angular/cli@latest
update the project dependencies
$ rm -rf node_modules dist $ npm install --save-dev @angular/cli@latest $ npm install
source: https://github.com/angular/angular-cli#updating-angular-cli
after that I updated angular-cli.json and following advice worked for me: https://github.com/angular/angular-cli/issues/3566
package.json file below -----
{ "name": "donsky-acc", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint "src/**/*.ts"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "^2.1.0", "@angular/compiler": "^2.1.0", "@angular/core": "^2.1.0", "@angular/forms": "^2.1.0", "@angular/http": "^2.1.0", "@angular/platform-browser": "^2.1.0", "@angular/platform-browser-dynamic": "^2.1.0", "@angular/router": "^3.1.0", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.23" }, "devDependencies": { "@angular/compiler-cli": "^2.1.0", "@types/jasmine": "^2.2.30", "@types/node": "^6.0.42", "angular-cli": "1.0.0-beta.20-4", "codelyzer": "~1.0.0-beta.3", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.9", "ts-node": "1.2.1", "tslint": "3.13.0", "typescript": "~2.0.3", "webdriver-manager": "10.2.5" } }
Please follow the steps listed here: https://github.com/angular/angular-cli#updating-angular-cli
And also remove angular-cli.
If afterwards, you still are having issues, please let us know.
still problem continues..
Macbook-pro:donsky_acc macbookpro$ npm install -g @angular/cli@latest
npm ERR! Darwin 14.5.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "@angular/cli@latest" npm ERR! node v7.5.0 npm ERR! npm v4.1.2
npm ERR! Cannot read property 'path' of null npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request: npm ERR! /Users/macbookpro/code/donsky_acc/npm-debug.log
{ "name": "donsky-acc", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint "src/**/*.ts"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "^2.1.0", "@angular/compiler": "^2.1.0", "@angular/core": "^2.1.0", "@angular/forms": "^2.1.0", "@angular/http": "^2.1.0", "@angular/platform-browser": "^2.1.0", "@angular/platform-browser-dynamic": "^2.1.0", "@angular/router": "^3.1.0", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.23" }, "devDependencies": { "@angular/compiler-cli": "^2.1.0", "@types/jasmine": "^2.2.30", "@types/node": "^6.0.42", "@angular-cli": "1.0.0-beta.31", "codelyzer": "~1.0.0-beta.3", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.9", "ts-node": "1.2.1", "tslint": "3.13.0", "typescript": "~2.0.3", "webdriver-manager": "10.2.5" } }
changed angular-cli to @angular-cli in the devdependencies on package.json file
You have to be inside an Angular CLI project in order to use the serve command.
@angular/cli not @angular-cli
God, this isn't very much fun is it :(
Where's TypeScript 2.1 support ? Does it work ?
made the change @angular/cli still not working, this is not fun at all.
package.json
{ "name": "donsky-acc", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint "src/**/*.ts"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "^2.1.0", "@angular/compiler": "^2.1.0", "@angular/core": "^2.1.0", "@angular/forms": "^2.1.0", "@angular/http": "^2.1.0", "@angular/platform-browser": "^2.1.0", "@angular/platform-browser-dynamic": "^2.1.0", "@angular/router": "^3.1.0", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.23" }, "devDependencies": { "@angular/compiler-cli": "^2.1.0", "@types/jasmine": "^2.2.30", "@types/node": "^6.0.42", "@angular/cli": "1.0.0-beta.31",
"codelyzer": "~1.0.0-beta.3",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
} }
Having the same issue, after an angular-cli -> @angular/cli upgrade. It's an unmet peerdep with @angular/cli-compiler.
Fixed by doing:
npm uninstall angular-cli -g
npm uninstall angular-cli --save
npm install -g @angular/cli
npm install @angular/cli --save
npm install @angular/compiler-cli --save
However, surely there's a better way.
macbook-pro:donsky_acc macbookpro$ sudo npm install @angular/cli --save Password: npm ERR! Darwin 14.5.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "@angular/cli" "--save" npm ERR! node v7.5.0 npm ERR! npm v4.1.2 npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 74.125.224.72:8888 npm ERR! network This is most likely not a problem with npm itself npm ERR! network and is related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request: npm ERR! /Users/macbookpro/code/donsky_acc/npm-debug.log
this problem still continues, thanks ssayan for your note