node.js - 如何完全卸载 npm 安装的所有内容(即如何确保安装了 npm 的全新安装)?

标签 node.js angular npm

我在 Angular、ng 等方面遇到了一些版本问题。我想从头开始,卸载所有已安装的东西,然后重新开始。我在 Windows 上。

我在这里找到了一些信息: https://docs.npmjs.com/misc/removing-npm.html

我从 cmd 行运行它,它似乎没有做任何事情: npm 卸载 npm -g

我以管理员身份重新运行,它删除了我安装的一些东西,但不是全部。

这是来自没有管理员的 cmd:

C:\>npm uninstall npm -g
up to date in 0.12s

C:\>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.1.1
Node: 12.16.2
OS: win32 x64

Angular: 9.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.1
@angular-devkit/build-angular     0.901.1
@angular-devkit/build-optimizer   0.901.1
@angular-devkit/build-webpack     0.901.1
@angular-devkit/core              9.1.1
@angular-devkit/schematics        9.1.1
@angular/cdk                      7.3.7
@angular/material                 7.3.7
@ngtools/webpack                  9.1.1
@schematics/angular               9.1.1
@schematics/update                0.901.1
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

这是以管理员身份运行后剩下的:

c:\>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.1.1
Node: 12.16.2
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.901.1
@angular-devkit/core         9.1.1
@angular-devkit/schematics   9.1.1
@schematics/angular          9.1.1
@schematics/update           0.901.1
rxjs                         6.5.4


c:\>

最佳答案

package.json 文件中的这些命令可能会派上用场。您也可以手动删除 node_modules 文件夹,调整 package.json 中的依赖项并重新安装。

"build": "npm build",
"clean": "rm -rf node_modules", 
"reinstall": "npm run clean && npm install", 
"rebuild": "npm run clean && npm install && npm run build",

编辑:我忘了在 Windows 中输入清理命令: "clean":"rmdir/s/q node_modules"

此外,如果您的问题与全局 angular/cli 包有关,您可以: npm uninstall -g angular-cli 卸载 angular/cli。 npm cache clean 从您用户名下的应用程序数据文件夹中清除您的 npm 缓存。 使用 npm cache verify 验证您的缓存是否已损坏。 使用 npm cache verify --force 清除系统中的整个缓存。

注意: 您也可以通过以下路径删除 C:\Users\"Your_syste_User_name"\AppData\Roaming\npm 和 C:\Users\"Your_syste_User_name"\AppData\Roaming\npm-cache 然后使用以下命令在您的系统中全局安装最新的 angular/cli 版本。 npm install -g @angular/cli@latest

关于node.js - 如何完全卸载 npm 安装的所有内容(即如何确保安装了 npm 的全新安装)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61229984/

相关文章:

javascript - n 模块中断 npm

javascript - 如何在javascript中分解一个url

node.js - npm:禁用包的安装后脚本

node.js - ENOENT,fs.mkdirSync 上没有这样的文件或目录

angular - rxjs observable.interval();在浏览器中抛出不是函数异常

angular - 如何在 Angular 2 final 中扩展 Angular 2 http 类

node.js - 悬挂/卡住物化 :prettier: timing reifyNode:node_modules/@nrwl/workspace Completed in 12729ms

node.js - 如何检查给定查询是否在 knex 中返回任何结果

javascript - 不使用 angular 中的 javascript 在 div 上设置属性值

javascript - 信号客户端的 npm 包未连接