我正在尝试将我的angular cli版本更新到最新版本,为此我正在做:
npm uninstall -g @angular/cli
npm cache verify
之后,我关闭并再次打开终端,在一个空文件夹中键入:
ng -v
输出为:6.2.0
我还尝试安装了最新版本的angular with:
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服务",效果很好。
在新的空目录中尝试下面的代码。
npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli
npm cache verify
npm install -g @angular/cli
ng v
好吧,这是我的错,在我的.bashrc中,我将"ng"重定向到了"npm use ng"。
对不起,谢谢大家