NPM清洁模块

node.js Node.js

西里神奇

2020-04-03

有没有办法让npm解压node_modules下的所有模块?诸如npm rebuild之类的东西会删除所有构建工件,但不重建它们吗?

第4019篇《NPM清洁模块》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

6个回答
Mandy 2020.04.03

我在package.json中添加了几行:

"scripts": {
  ...
  "clean": "rmdir /s /q node_modules",
  "reinstall": "npm run clean && npm install",
  "rebuild": "npm run clean && npm install && rmdir /s /q dist && npm run build --prod",
  ...
}

If you want to clean only you can use this rimraf node_modules.

神无 2020.04.03

我将此添加到我的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",

似乎运作良好。

JinJin 2020.04.03

一句话没有

二,没有

但是,--no-build标记在npm install不进行构建的情况下执行安装存在一个未解决的问题,该问题可用于完成您所要求的操作。

看到这个未解决的问题

GO 2020.04.03

您可以删除node_module目录

rm -rf node_modules/
Stafan路易 2020.04.03

尝试 https://github.com/voidcosmos/npkill

npx npkill

它将找到所有node_modules并让您删除它们。

npkill

Stafan 2020.04.03

对于Windows环境:

"scripts": {
    "clean": "rmdir /s /q node_modules",
    ...
}

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android