Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

bug(schematics): Cannot find module '@angular-devkit/core' #256

Closed
meDavid opened this issue Nov 3, 2017 · 44 comments
Closed

bug(schematics): Cannot find module '@angular-devkit/core' #256

meDavid opened this issue Nov 3, 2017 · 44 comments

Comments

@meDavid
Copy link

meDavid commented Nov 3, 2017

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request

Area

- [ ] devkit
- [X ] schematics

Versions

node 6.9.1
npm 5.4.2
Windows 10

Repro steps

If you globally install @angular-devkit/schematics and try to create a new schematic using
schematics @schematics/schematics:schematic --name=SomeSchematicName you will get the following error:

The log given by the failure

Error: Cannot find module '@angular-devkit/core'
    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.<anonymous> (C:\......\node_modules\@schematics\schematics\schematic\factory.js:10:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Desired functionality

No errors and a generated new schematics blueprint

Mention any other details that might be useful

the @schematics/schematics:schematic factory uses a dependency on @angular-devkit/core, but this dependency is not in the package.json

@theoomoregbee
Copy link

theoomoregbee commented Jan 18, 2018

Yea same issue here, after uninstalling angular-cli then after installing the latest angular-cli,
ng help boom this

@theoomoregbee
Copy link

theoomoregbee commented Jan 18, 2018

npm install -g @angular-devkit/core fixed it anyway
related to this angular/angular-cli#9190

@rathodmitesh916
Copy link

rathodmitesh916 commented Jan 18, 2018

@Theo4u
So should I just add it to my package.json if angular-cli uses it internally? Because we don't use this module in our code base.

@theoomoregbee
Copy link

theoomoregbee commented Jan 18, 2018

@jainmitesh09 Oh can't really say, since it's in the pkgjson .
https://github.com/angular/angular-cli/blob/9c871b003a8d91051e9d7affc63206aef4b71e20/package.json#L45

But i added it to mine to stop the error when running local commands like ng serve --> npm install @angular-devkit/core --save-dev

@szkrd
Copy link

szkrd commented Jan 18, 2018

Same here. As a quick fix npm i -D @angular-devkit/core in the project folder fixed it for me.

@germs12
Copy link

germs12 commented Jan 18, 2018

I rolled back to angular-cli 1.6.3

@mmercure
Copy link

mmercure commented Jan 18, 2018

It seems that some dependencies became peerDependencies. :(

But restarting from scratch now works because of newer version just deployed

@ankemp
Copy link

ankemp commented Jan 18, 2018

Taking @germs12 advice, I rolled back to 1.6.3. But then I re-installed 1.6.4 and everything seems to be working again.

@merobal
Copy link

merobal commented Jan 18, 2018

I don't know what happened, I got the same error during npm install ~1 hour ago, but now everything worked fine again (without any change from my side meantime).

@filipesilva
Copy link
Contributor

There was indeed a bad release about 1h ago but we've since rolled back and republished the previous version while we work on a real fix.

@hansl
Copy link
Contributor

hansl commented Jan 18, 2018

See angular/angular-cli#9276

@hansl hansl closed this as completed Jan 18, 2018
@meDavid
Copy link
Author

meDavid commented Jan 18, 2018

@hansl This ticket was about schematics, not the devkit / cli

@hansl
Copy link
Contributor

hansl commented Jan 18, 2018

Sorry, i just wanted to add the following as context:

We just released an emergency patch for the devkit and are working to release a patch for 1.4 and 1.5 that will fix this retroactively. After this we will re-release the CLI and the devkit.

@germs12
Copy link

germs12 commented Jan 19, 2018

I've cleared everything out and reinstalled. So far nothing is working. I have a feeling it's due to some cached version of the CLI on my computer.

Amusing part of this for me is this: I was researching the problem for an issue in AWS CodeBuild. Fixed that, but now I can't get ng to work on my local machine!

Thanks @hansl for you and your teams work.

@nnennajohn
Copy link

nnennajohn commented Jan 19, 2018

I should have checked this a minute ago before upgrading. :(

Does anyone know what is the latest working version?

After upgrading, I got the error for missing devkit. Installed it. And now I have this error.

screenshot 2018-01-18 16 38 32

@KWFE
Copy link

KWFE commented Jan 19, 2018

@germs12 just run this command in your prompt ""npm install -g @angular-devkit/core"" i think it will fix your problem

@nnennajohn
Copy link

@germs12 Uninstalling latest and install

npm install -g @angular/cli@1.6.3 @angular-devkit/core

worked for me. At least until a fix to current bug.

shaojianyong added a commit to shaojianyong/eztrans that referenced this issue Jan 19, 2018
absshingate pushed a commit to shingate/sensoil that referenced this issue Jan 19, 2018
@ediri
Copy link

ediri commented Jan 19, 2018

@nnennajohn : Did not worked for me...

For me

npm install @angular-devkit/core --save-dev

did the trick.

ruromero added a commit to ruromero/break-fix that referenced this issue Jan 19, 2018
mrbatista added a commit to mrbatista/ngx-loader that referenced this issue Jan 19, 2018
- block angular cli to version 1.6.3 until the issue
angular/angular-cli#9185 is resolved
- add angular-devkit/core to dev dependencies until the issue
angular/devkit#256 is resolved
@MateuszStefek
Copy link

For me this is like the fifth time during the past 3 months that the community around npm & angular managed to somehow break the fundamental rule of any sane package repository: the published versions never ever change.
If I have a package.json with only fixed versions and I don't modify the code, then my builds should work every single day. How am I supposed to deliver a software package, if I cannot guarantee it will even build on a random day?

@reachbikramsingh
Copy link

@nnennajohn Not working for me
npm install @angular-devkit/core

@pgrm
Copy link

pgrm commented Jan 19, 2018

@MateuszStefek we're using yarn and I can't recall having any issues since switching to yarn.

The only thing is that our nightly job which tries updating the yarn lock file failed few times, but mostly it's working again the next night, or it's super easy to fix. It really is up to you to make sure that you always have the same package dependencies, that's why there are lock files, so use them

@filipesilva
Copy link
Contributor

filipesilva commented Jan 19, 2018

I'd like to remind everyone that you only have reproducible installs if you use a lockfile. Both NPM v5+ and Yarn support lockfiles. If your CI works one day but not the next and you did not change your code or package.json, it is likely because one of your dependencies had a bad release and you did not have a lockfile.

It is your responsibility as a library consumer to use lockfiles. No one wants to do a release with bugs but it sometimes happens, and the best we can do is to fix it as fast as possible with a new release. When you have a couple of thousand total dependencies it is only a matter of time until one of them has a bad release.

@dolanmiu
Copy link

dolanmiu commented Jan 19, 2018

I am getting this on my local machine and my build server

Surely a package-lock file would prevent this from happening

@ediri's workaround fixed it. But probs not a long term solution

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Developer\p\node_modules\@angular-devk
it\schematics\src\tree\virtual.js:10:16)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

@attina-claudia
Copy link

Hello all,

In the package.json I have:
"dependencies": {
"@angular/animations": "^5.0.5",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.5.5",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}

And I also use a lockfile package-lock.json
"@angular-devkit/core": {
"version": "0.0.22",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-0.0.22.tgz",
"integrity": "sha512-zxrNtTiv60liye/GGeRMnnGgLgAWoqlMTfPLMW0D1qJ4bbrPHtme010mpxS3QL4edcDtQseyXSFCnEkuo2MrRw==",
"dev": true,
"requires": {
"source-map": "0.5.7"
}
},
"@angular-devkit/schematics": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-0.0.39.tgz",
"integrity": "sha512-YoXE7mej7ARdjpiNAsg2NguIe8e3BusZRUQ7xA10AMftuPVZV2v7vV0M0j1vmH2WFEK8Tn4TqHsd5njDcvwX4g==",
"dev": true,
"requires": {
"@angular-devkit/core": "0.0.22",
"@ngtools/json-schema": "1.1.0",
"minimist": "1.2.0",
"rxjs": "5.5.3"
}

Why am i getting this error? And how can I fix it?
The only solution is to add the devkit/core as a dependency in my package.json file?

Thank you

@filipesilva
Copy link
Contributor

Please see angular/angular-cli#9276 (comment) for a list of latest versions that have this problem fixed.

@attina-claudia
Copy link

attina-claudia commented Jan 19, 2018

Hi Filipe,

Thank you.
So I've changed my in package.json : "devDependencies": {
"@angular/cli": "1.5.6",
....
}

Should I change something in the package-json.lock file? (I did not get the comment with "It is your responsibility as a library consumer to use lockfiles")

"@angular/cli": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@angular/cli/-/cli-1.5.5.tgz",
"integrity": "sha512-qAooJraZwT9o2W7yx6gY6fnc7PEMlGzu60ELZJfC51MnoYMPKiIEFYeWanCSNju1P7jfpeBXuwp1qEMZCX73Zw==",
"dev": true,
"requires": {
// don't know why is not displaying correctly the first 5
"@angular-devkit/build-optimizer": "0.0.34", //angular-devkit/build-optimize
"@angular-devkit/schematics": "0.0.39", //angular-devkit/schematics
"@ngtools/json-schema": "1.1.0", //ngtools/json-schema
"@ngtools/webpack": "1.8.5", //ngtools/webpack
"@schematics/angular": "0.1.9", //schematics/angular
"autoprefixer": "6.7.7",
"chalk": "2.2.2",
"circular-dependency-plugin": "3.0.0",
"common-tags": "1.5.1",
"copy-webpack-plugin": "4.2.3",
"core-object": "3.1.5",
"css-loader": "0.28.7",
"cssnano": "3.10.0",
"denodeify": "1.2.1",
"ember-cli-string-utils": "1.1.0",
"exports-loader": "0.6.4",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "1.1.5",
"fs-extra": "4.0.2",
"glob": "7.1.2",
"html-webpack-plugin": "2.30.1",
"istanbul-instrumenter-loader": "2.0.0",
"karma-source-map-support": "1.2.0",
"less": "2.7.3",
"less-loader": "4.0.5",
"license-webpack-plugin": "1.1.1",
"lodash": "4.17.4",
"memory-fs": "0.4.1",
"minimatch": "3.0.4",
"node-modules-path": "1.0.1",
"node-sass": "4.7.2",
"nopt": "4.0.1",
"opn": "5.1.0",
"portfinder": "1.0.13",
"postcss-custom-properties": "6.2.0",
"postcss-loader": "2.0.9",
"postcss-url": "7.3.0",
"raw-loader": "0.5.1",
"resolve": "1.5.0",
"rxjs": "5.5.3",
"sass-loader": "6.0.6",
"semver": "5.4.1",
"silent-error": "1.1.0",
"source-map-loader": "0.2.3",
"source-map-support": "0.4.18",
"style-loader": "0.13.2",
"stylus": "0.54.5",
"stylus-loader": "3.0.1",
"uglifyjs-webpack-plugin": "1.0.0",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-concat-plugin": "1.4.0",
"webpack-dev-middleware": "1.12.2",
"webpack-dev-server": "2.9.5",
"webpack-merge": "4.1.1",
"webpack-sources": "1.1.0",
"webpack-subresource-integrity": "1.0.2",
"zone.js": "0.8.18"
}

Thank you,
A.

@filipesilva
Copy link
Contributor

@attina-claudia after updating your package.json, run npm install and package-lock.json should be updated automatically.

By It is your responsibility as a library consumer to use lockfiles I mean that you, as a consumer that wants reproducible installs, must use and maintain lockfiles. No one can do it but you, and it is the only way to ensure repeated installs will yield the same dependency set.

@victorcodex
Copy link

victorcodex commented Jan 19, 2018

npm i --save-dev @angular-devkit/core should fix it.

This issue is related to the latest Angular cli from v1.6>

I hope this will be fixed in the upcoming Angular cli update

@jonataSouza
Copy link

jonataSouza commented Jan 19, 2018

For me,
npm install @angular-devkit/core --save-dev

@cjcarvajal
Copy link

In Mac, i just ran ng new my-project and then inside the project folder ng s I see the same error, I reinstall @angular/cli and ran npm install @angular-devkit/core --save-dev

@sumitpatel19990
Copy link

sumitpatel19990 commented Jan 20, 2018

@my issue solve by this command:
=> npm i --save-dev #@angular-devkit/core
=> ng serve

@andreafino
Copy link

This works for me npm i -D @angular-devkit/core

@afzal00
Copy link

afzal00 commented Jan 20, 2018

You can also simply try this

npm i @angular-devkit/core

@prasworld
Copy link

prasworld commented Jan 20, 2018

npm i -D @angular-devkit/core
did not work , however i had to reinstall cli

@HammaniMourad
Copy link

HammaniMourad commented Jan 20, 2018

npm i --save-dev #@angular-devkit/core

by :sumitpatel19990

@attina-claudia
Copy link

Hi.
Adding angular-devkit/core to your devDependencies is not a proper solution.
As Filipe said, we need to have a lock file (package-lock.json) but make sure that you have npm v5+ (i had an older version and the lock file was ignored). If you don't have one, update angular-cli to 1.5.6. Run npm install.
Should work.

@HammaniMourad
Copy link

HammaniMourad commented Jan 21, 2018 via email

@merobal
Copy link

merobal commented Jan 22, 2018

They fixed this issue at angular-cli v1.6.5 by this commit: angular/angular-cli@c7aefaa and it works well for me without adding angular-devkit/core to my package.json. I just updated the CLI to the latest (v1.6.5) version.

@inyee786
Copy link

inyee786 commented Jan 25, 2018

@Theo4u thanks it worked for me npm install @angular-devkit/core --save-dev

@piyarulps
Copy link

piyarulps commented Jan 30, 2018

This works for me ................

just run: npm i @angular-devkit/core --save

......................................................................................

@ashits8118
Copy link

thnx guys npm install @angular-devkit/core --save-dev , it worked for me

@ViniciusBVilar
Copy link

@merobal Thank you! Worked for me!

@sabbarbutt
Copy link

I struggled with the same problem. My project was generated using the v 1.6.0 of angular-cli.

npm update -g @angular/cli
editing my package.json changing the line
"@angular/cli": "1.6.0",
to
"@angular/cli": "^1.6.0",
npm update
did the trick.

@webmasters964
Copy link

Error: Cannot find module '@angular-devkit/core'

errorcapture

npm install @angular-devkit/core --save-dev

runcapture

its working fine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests