我正在尝试将我的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 ]
我还尝试在一个现有项目上进行“服务”,效果很好。
我可以寻求帮助吗?
谢谢。
答案 0 :(得分:0)
在新的空目录中尝试下面的代码。
npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli
npm cache verify
npm install -g @angular/cli
ng v
答案 1 :(得分:0)
好吧,这很糟糕,在我的.bashrc中,我将“ ng”重定向到“ npm use ng”。
对不起,谢谢大家