[英]How can I tell node to use a particular installed package version?
如果我的系统上安装了foo软件包的1.1和1.2版本,并且bar.js需要foo软件包,是否有一种方法可以调用node bar.js
以便该节点使用foo的1.1版本?
NPM packages that are local to the project stay in node_modules
and don't update unless you explicitly update them yourself. 项目本地的NPM软件包保留在
node_modules
,除非您自己明确更新它们,否则它们不会更新。 You can use NPM's semantic versioning to manage the granularity of your dependencies on a per-project basis. 您可以使用NPM的语义版本控制来按项目管理依赖项的粒度。 Here's a semver cheat sheet: https://semver.npmjs.com/
这是semver备忘单: https ://semver.npmjs.com/
With that in mind, where this breaks down is if you're installing modules globally (which you should not be doing unless the package owner tells you to, eg Grunt or Angular-CLI). 考虑到这一点,在这个分解是,如果你安装全局模块(你不应该做,除非包所有者告诉你,如步兵或角CLI)。 If you are using global modules and you don't need to be, you should fix that ;)
如果您正在使用全局模块而不必这样做,则应修复该问题;)
If you find that semantic versioning is causing conflicts for dependencies within your project (eg foo requires bar 1.0 and faa requires bar 1.1) OR you are concerned about the risk of breaking dependency changes, take a look at Yarn . 如果您发现语义版本引起冲突为您的项目内的相关性(如FOO要求巴1.0和FAA要求吧1.1),或者你担心打破依赖变动的风险,看一看纱 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.