0

I have installed angular cli 1.5 from the command below:

C:\ANGULAR-WORKBENCH>npm install --global @angular/[email protected]

after completion of installation the following lines were displayed on terminal

+ @angular/[email protected]
added 115 packages and updated 1 package in 105.694s

Then I have tested if it was successfully installed by

C:\ANGULAR-WORKBENCH>ng -version

or

C:\ANGULAR-WORKBENCH>ng

In Both cases it displayed the error

module.js:538 throw err; ^
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. (C:\Users\User1\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\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)

Why this throws the error? How do i fix this issue?

2
  • 1
    This isn't something SO can help with, it's a known issue in a third party library. Commented Mar 10, 2018 at 13:46
  • Is version 1.5.0 a must for you? Otherwise I would take the @latest. I had the same problem as you with a newer version of the cli and by installing the latest version globally and locally the problem was solved. Commented Mar 10, 2018 at 14:04

4 Answers 4

1

Perhaps the problem is that you are installing and old angular/cli version, try running this commands in your terminal:

npm uninstall -g angular-cli
npm cache clean or npm cache verify #(if npm > 5)
npm install -g @angular/cli@latest

If you need more datailed explanation please check this link: https://stackoverflow.com/a/43931987/8992452, it worked for me.

Sign up to request clarification or add additional context in comments.

Comments

0

You're using an old angular cli version. Try updating it:

$ npm install -g @angular/cli@^1.6.5 

Comments

0

All you need to do is run npm i -D @angular-devkit/core in the working directory to fix it.

7 Comments

Actually, no. The OP hasn't even build a new project yet. The command above would fail if you just run that without being in a project folder.
Since the issue was cropped up by running ng serve, I assumed that he is currently in the working directory
The OP doesn't mention ng serve. ng and ng -version, but not serve.
I have edited my answer, I hope it is correct now @ R. Richards
@Vikas i did run npm i -D @angular-devkit/core but still gives the same issue
|
0

In some systems, ng commands won't work (Usually in company laptops). Anyway, npm commands will run. So the workaround would be in the package.json file to add the relevent scripts to run your project.

For instance, if you want to start your project, the Angular way would be: ng server.

But you can also run npm start.

To build your project, add the ng build <some-options> into the package.json scripts object. For example, scripts: {"build": "ng build --aot=false"}

Then run npm run build.

Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.