hello guys I have this next error when I try run my App from the terminal(linux), when I run this command:
ng serve
and I get this error in my terminal:
AppBlog/blog# ng serve An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' Require stack: - /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js - /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js - /usr/local/lib/node_modules/@angular/cli/models/architect-command.js - /usr/local/lib/node_modules/@angular/cli/commands/serve-impl.js - /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js - /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js - /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js - /usr/local/lib/node_modules/@angular/cli/models/command-runner.js - /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js - /usr/local/lib/node_modules/@angular/cli/lib/init.js - /usr/local/lib/node_modules/@angular/cli/bin/ng See "/tmp/ng-ev5aDi/angular-errors.log" for further details.
then i checked out this part :
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
this part say that cannot find moduled called: "'@angular-devkit/build-angular/package.json'"
then I cheked out this file in my project but I have this, look:
"devDependencies": { "@angular-devkit/build-angular": "~0.900.3", "@angular/cli": "~9.0.3", "@angular/compiler-cli": "~9.0.2", "@angular/language-service": "~9.0.2", "@types/node": "^12.11.1", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.1.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.2", "protractor": "~5.4.3", "ts-node": "~8.3.0", "tslint": "~5.18.0", "typescript": "~3.7.5" }
then i went to google and search and I found this like from stackoverflow and I tried their solution but it does not work and I run the command ng serve again.
what I did wrong?
before nothing , before I added 3 components: login,register and home in my folder : src/app with this command : ng generate component login and I import my component in my file : app.component.ts this way:
/* THIS IS JUST A EXAMPLE VERY SIMILAR TO MY CODE REAL, I just import one component*/ import { Component } from '@angular/core'; import { loginComponent } from './login.component'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], declarations: [loginComponent], //import my login }) export class AppComponent { title = 'blog'; }
maybe is this part but I dont find a solution, any expert in angular could tell me what I did wrong?
UPDATE
I am continue searching in google and I found this: github/Angular they are saying that I would install npm/angular-cli/node again and I run this command for update my angular cli:
uninstalled ang-cli
npm uninstall @angular/cli
installed the latest
npm install -g @angular/cli@latest
but first I update my npm with this command:
installed the latest npm
npm install -g npm@latest
but it still does not work.
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.
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.
This package contains Architect builders used to build and test Angular applications and libraries.
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.
Please try installing the npm on a project folder. I had installed npm globally but installing the npm once again on a solution folder fixed my issue.
npm install
in the project folder will do the trick. Then do ng serve -o
I finally found something working for me.
Add --force
at the end of your npm command.
Like npm install --save-dev @angular-devkit/build-angular --force
Then ng serve
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