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条回答
The star\"
2楼-- · 2019-01-30 21:16

Below steps worked for me:

Delete node_modules folder and package-lock.json file. npm install ng serve

查看更多
该账号已被封号
3楼-- · 2019-01-30 21:17

i got the same issue, and the reason is

  1. when you run ng new app-name it will create a new directory with app name and install everything in that.
  2. after running the above command, human tendency is to run ng serve and because your app is in sub directory it will not find package.json and throw the mentioned error.

Solution is pretty simple. just move to the sub directory and then run ng serve

查看更多
一纸荒年 Trace。
4楼-- · 2019-01-30 21:17

You create new project with:

ng new firstngapp

In your example you are missing new. This would create folder, generate files and run npm install for you. It seems that you've created folder but there's no Angular CLI app in it.

And for starting the app use:

ng serve

npm start is only used if you have ejected from cli.

查看更多
贪生不怕死
5楼-- · 2019-01-30 21:18

Try to run

npm install

in the project folder

查看更多
smile是对你的礼貌
6楼-- · 2019-01-30 21:20

May help you.

  • Delete All folders you have created previously
  • Create fresh folder
  • Then try navigate to that folder from command "cd foldername"
  • then try to install "npm install"

This will solve you problem.

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-01-30 21:20

**You should be in the newly created YOUR_APP folder before you hit the ng serve command **

Lets start from fresh,

1) install npm

2) create a new angular app ( ng new <YOUR_APP_NAME> )

3) go to app folder (cd YOUR_APP_NAME)

4) ng serve

I hope it will resolve the issue.

查看更多
登录 后发表回答