gpt4 book ai didi

angular - 重新正确安装 Angular

转载 作者:行者123 更新时间:2023-12-01 21:55:20 26 4
gpt4 key购买 nike

我在 Angular 中的依赖项有问题,所以我在我的项目中重新安装了它。所以,我所做的是:

npm uninstall -g angular-cli
npm cache clean or npm cache verify
npm install -g @angular/cli@latest

rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

但是现在,当尝试使用 npm start 或 ng serve 时,会发生这种情况

The serve command requires to be run in an Angular project, but a project definition could not be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular@0.0.0 start script.

除此之外,在尝试 npm install 命令时我收到奇怪的警告:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 7337 packages in 4.116s
found 20 vulnerabilities (3 low, 14 moderate, 3 high)

它在卸载之前有效(依赖项除外)所以我真的很沮丧。

当然,我在谷歌搜索这个问题时发现的第一件事是

Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found

但是这样做之后,问题依旧存在。

如何正确地重新安装 Angular?

最佳答案

试试这个,

    npm uninstall -g angular-cli
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

然后当它成功完成时你可以尝试:

ng --version

关于angular - 重新正确安装 Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58080283/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com