I'm a little new to Angular, so apologies if this question has been asked many times. Certainly, I have found MANY github issues with similar symptoms, but no clear solution (or it's a problem that keeps coming back).
I installed whatever the latest version of Angular comes from npm:
npm install -g @angular/cli
When I run ng
(with any options, even if just ng --version
), I get the following error:
module.js:540 throw err; ^ Error: Cannot find module '@angular-devkit/core' at Function.Module._resolveFilename (module.js:538:15) ... ...
Installing @angular-devkit/core
seems to fix the problem:
npm install -g @angular-devkit/core
... well, almost...
I then have to make sure I ALSO install the same devkit component for each application:
npm install --save @angular-devkit/core
Is there a problem with Angular's packaging?
Do they deliberately leave out the devkit/core component, or just an accident with some versions?
OR, Could it be that I am doing something wrong?
SOFTWARE VERSIONS:
To solve the error "Could not find module '@angular-devkit/build-angular'", make sure to install the package by opening your terminal in your project's root directory and running the following command: npm i -D @angular-devkit/build-angular and restart your IDE and development server.
Angular CLI, Angular Schematics, and Angular DevKit DevKit was built to provide libraries that can be used to manage, develop, deploy, and analyze your code. DevKit has a schematics-cli command line tool that you can use to create your own Schematics.
Please remove both the "node_modules" directory and the package lock file; and then reinstall. If this does not correct the problem, please temporarily install the "@angular-devkit/schematics" package within the workspace. It can be removed once the update is complete.
To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the baseUrl option to src in your tsconfig. json file and restart your IDE and development server.
Actually, all you need is to add missing @angular-devkit/core
. For some reason it's missing in the new ng new
process.
npm i --save-dev @angular-devkit/core
Of course since this is broken in 1.6.0 version you should upgrade your global @angular/cli
and also your local in the project. This would make more permanent fix. The latest version also fixes missing devkit core dependency:
npm i -g @angular/cli@latest npm i --save-dev @angular/cli@latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With