我正在尝试将我的 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”,效果很好。