You seem to not be depending on “@angular/core”. T

2019-01-30 20:33发布

I want to create an angular 2 App with angular cli

I have written in the cmd:

npm install angular-cli -g

then:

ng firstngapp

but it show me an error when I write npm start ! the error image

Files image

I don't understand the problem

27条回答
Emotional °昔
2楼-- · 2019-01-30 21:05

I was getting the same error when I tried to run "ng serve" after that I saw some suggetions one of the techie told me to update my npm.I did that as well then I got this screen after entering "ng server"

""Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install. Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_module and package-lock.json(if you have one) and Run npm install again.""

After performing all the actions now its working correctly...and getting message "Compiled Successfully."

查看更多
一夜七次
3楼-- · 2019-01-30 21:06

This is how I solved this problem.

I first ran npm install @angular/core.

Then I ran npm install --save.

When both installs had successfully completed I ran npm serve and received an error saying

"Versions of @angular/compiler-cli and typescript could not be determined.
The most common reason for this is a broken npm install.

Please make sure your package.json contains both @angular/compiler-cli and typescript in
devDependencies, then delete node_modules and package-lock.json (if you have one) and
run npm install again."

I then deleted my node_modules folder as well as my package-lock.json folder.

After I deleted those folders I ran npm install --save once more.

I ran npm start and received another error. This error said Error: Cannot find module '@angular-devkit/core'.

I ran npm install @angular-devkit/core --save.

Finally, I ran npm start and the project started!

查看更多
Ridiculous、
4楼-- · 2019-01-30 21:07

the fix for me was

npm link
ng build 

enter image description here

查看更多
Deceive 欺骗
5楼-- · 2019-01-30 21:08

After trying to no avail:

  • npm install
  • npm update
  • ng serve

npm install -g @angular/cli worked for me

查看更多
6楼-- · 2019-01-30 21:08

I had the same issue and along with removing the node_modules and reinstalling I needed to remove package-lock.json first.

查看更多
Animai°情兽
7楼-- · 2019-01-30 21:09

You need to run the ng server from the c:\project\angular-src location. Not just the root of your project.

查看更多
登录 后发表回答