简体   繁体   English

如何告诉节点使用特定的已安装软件包版本?

[英]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.

相关问题 如何判断节点是如何安装的? - How to tell how node was installed? 仅当节点的版本足够旧时,我才需要软件包吗? - How can I require a package only if the version of node is old enough? 如何告诉gulp使用哪个版本的node-webkit - How to tell gulp which version of node-webkit to use 如何在项目中使用npm软件包的自定义版本? - How can I use a custom version of a npm package in my project? 如何判断 npm 包是全局安装还是本地安装 - How to tell if npm package was installed globally or locally 如何将所有已安装的节点模块保存在package.json中? - How can I save all the installed node modules in package.json? 如何打包Node Web应用程序以便可以将其安装为本地应用程序? - How do I package up a Node web app so it can be installed as a local app? Angular - 如何指定与系统上安装的版本不同的 node.js 版本? - Angular - How can I specify a different node.js version than what is installed on the system? 如何确定我的哪些依赖项取决于我的 node_modules 中的特定包? - How can I determine which of my dependencies depends on a particular package in my node_modules? 如何使用本地安装在 node_modules 中的包中的可执行文件? - How to use executables from a package installed locally in node_modules?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM