我可以通过复制node_modules来移动依赖库吗?

简单的讲,是可以的。但是每个人电脑环境的不同,node_module安装的顺序也不同,可能会出问题不同的问题,虽然说依赖树的结构并不影响您的工程,但为安全起见,如果遇到问题时,请直接在工程目录下面npm install,假设工程下有package.json文件。那么你将得到跟来源机器完全一样的依赖库。

npm v3 dependency installation is now non-deterministic meaning you may get different packages depending on the order in which packages have been installed over time. This isn't necessarily a bad thing, just something to be aware of.

npmv3依赖安装是不确定的了,意思是你将在不同的运行环境安装不同顺序的依赖包,一般不是件坏事,但要知道。

Given this change I personally don't copy my node_modules directory around too much (it's still possible though!) and instead opt for a clean install most of the time.

根据这个变化我个人是不经常复制node_modules(虽然仍有可能!)而是保留/opt/目录一个干净的安装版本。

There are new tools like Yarn Package Manager which can speed up the installation process if you are doing that a lot (but as of 2017-05-12 it's unclear how well it handles private npm organisations and private scoped packages).

这里介绍一个加速安装过程的包管理器Yarn Package Manager,如果你需要经常移动依赖包的话(但目前为止不确定对私有包管理的好不好)

So the takeaway is still pretty much the same: it won't hurt, but maybe err on the side of a clean install. If something weird does happen and you run into problems then you can just delete node_modules and run npm install.

所以结论仍是:无害,但可能出错,如果见鬼了,你可以直接干掉node_modules然后npm install

Thanks to https://stackoverflow.com/questions/24102022/is-it-safe-to-copy-node-modules

转载于:https://my.oschina.net/swingcoder/blog/909935

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值