Angular cli not using global npm install

2019-03-18 00:43发布

I am new to npm and node, i am learning angular.

In an angular cli project, whenever i run ng <<'keyword'>> command, i am getting below error as its unable to find global npm-modules folder.

node_modules appears empty, you may need to run npm install

Tried following configuration but no luck, i have to run npm install in every project to overcome the problem.

export NODE_PATH=/usr/local/lib/node_modules
PATH=$PATH:/usr/local/bin/node
PATH=$PATH:/usr/local/bin/npm

Is there way that i can avoid running npm install for every project?

6条回答
Anthone
2楼-- · 2019-03-18 01:24

You can avoid node_modules appears empty, you may need to run error by doing run following command : npm install -g@angular/cli

It will solve the problem.

查看更多
一夜七次
3楼-- · 2019-03-18 01:25

run cd folder_of_your_project

then run ng serve

查看更多
beautiful°
4楼-- · 2019-03-18 01:28

1- cmd > run ng version , to confirm that angular CLI was installed correctly

2- Be Sure that you are in the right folder/root (Probably is this your problem)

3 - then run : ng serve

查看更多
Deceive 欺骗
5楼-- · 2019-03-18 01:34

Follow the steps below

npm cache clean and than npm install

查看更多
疯言疯语
6楼-- · 2019-03-18 01:34

you need to be in the project structure folder to run ng serve or any other command once npm is installed in your system.you can check ng version in your root folder though.In the latest angular cli version the file is renamed as package.json where all dependencies are present.

查看更多
Fickle 薄情
7楼-- · 2019-03-18 01:39

i got the same error when I tried to run ng serve command after running ng new myapp and creating my project folder. This error occured because I didn't move in to the myapp folder I created. Once I used the cd myapp command and moved in to the folder ng serve worked successfully.

查看更多
登录 后发表回答