0

我正在尝试将我的 angular-cli 版本更新到最新版本,为此我正在这样做:

npm uninstall -g @angular/cli
npm cache verify

之后,我关闭并再次打开终端并输入一个空文件夹:

ng -v 

输出为:6.2.0

我还尝试使用以下方法安装最新版本的 Angular:

npm install -g @angular/cli@latest

然后执行

ng new my-app

但下一个错误显示:

npm ERR! path /home/<path>/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/raul/<path>/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/<my_name>/.npm/_logs/2018-11-09T23_58_11_085Z-debug.log

在那个日志里面我有:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'ng',
1 verbose cli   'new',
1 verbose cli   'my-app' ]
2 info using npm@6.2.0
3 info using node@v10.13.0
4 verbose stack Error: ENOENT: no such file or directory, open '/home/<path>r/package.json'
5 verbose cwd /home/<path>
6 verbose Linux 4.15.0-38-generic
7 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "run" "ng" "new" "my-app"
8 verbose node v10.13.0
9 verbose npm  v6.2.0
10 error path /home/<path>/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/home<path>/package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

我还尝试在现有项目上进行“ng serve”,效果很好。

4

2 回答 2

0

在新的空目录中尝试下面的代码。

npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli
npm cache verify
npm install -g @angular/cli
ng v
于 2018-11-10T00:36:48.750 回答
0

好的,这是我的错,在我的 .bashrc 中,我将“ng”重定向到“npm use ng”。

对不起,谢谢大家

于 2018-11-10T13:15:26.700 回答