有没有一个简单的方法重新安装我的应用程序所依赖的所有包(即他们在我的应用程序node_modules文件夹)?
当前回答
请按照此步骤重新安装节点模块并进行更新
即使node_modules文件夹不存在也可以工作。现在同步执行以下命令。你也可以使用“npm update”,但我认为这是更可取的方式
npm outdated // not necessary to run this command, but this will show outdated dependencies
npm install -g npm-check-updates // to install the "ncu" package
ncu -u --packageFile=package.json // to update dependencies version in package.json...don't run this command if you don't need to update the version
npm install: will install dependencies in your package.json file.
如果你对包中依赖项的版本没有问题。Json文件,不需要遵循这些步骤,只需运行
npm install
其他回答
npm更新了用于安装的CLI命令,并添加了——force标志。
npm install --force
——force(或-f)参数将强制npm获取远程资源,即使磁盘上存在本地副本。
参见npm install
你可以用一个简单的命令来做到这一点:
npm ci
以下是npm ci文档的节选:
In short, the main differences between using npm install and npm ci are: The project must have an existing package-lock.json or npm-shrinkwrap.json. If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock. npm ci can only install entire projects at a time: individual dependencies cannot be added with this command. If a node_modules is already present, it will be automatically removed before npm ci begins its install. It will never write to package.json or any of the package-locks: installs are essentially frozen.
你可以在Windows上使用
(if exist node_modules rmdir node_modules /q /s) && npm install
删除node_modules目录,然后执行NPM安装。安装前删除可确保重新安装所有包。
请按照此步骤重新安装节点模块并进行更新
即使node_modules文件夹不存在也可以工作。现在同步执行以下命令。你也可以使用“npm update”,但我认为这是更可取的方式
npm outdated // not necessary to run this command, but this will show outdated dependencies
npm install -g npm-check-updates // to install the "ncu" package
ncu -u --packageFile=package.json // to update dependencies version in package.json...don't run this command if you don't need to update the version
npm install: will install dependencies in your package.json file.
如果你对包中依赖项的版本没有问题。Json文件,不需要遵循这些步骤,只需运行
npm install
从npm cli v6.5.0开始,你可以使用backronym:
npm clean-install
来源:
https://github.com/npm/cli/releases/tag/v6.5.0 https://github.com/npm/cli/commit/fc1a8d185fc678cdf3784d9df9eef9094e0b2dec
推荐文章
- ReferenceError: description没有定义NodeJs
- 将一个二进制的NodeJS Buffer转换为JavaScript的ArrayBuffer
- AngularJS只适用于单页应用程序吗?
- 如何在vue-cli项目中更改端口号
- 如何查看npm包的大小?
- 同步和异步编程(在node.js中)的区别是什么?
- 如何编辑通过npm安装的节点模块?
- “node_modules”文件夹应该包含在git存储库中吗
- 使用package.json在全局和本地安装依赖项
- this.libOptions.parse不是一个函数
- 对嵌套文件夹运行npm install的最好方法是什么?
- 节点Multer异常字段
- 在Ubuntu上安装Bower
- 很好的初学者教程socket.io?
- CALL_AND_RETRY_LAST分配失败-进程内存不足