简体   繁体   English

开发和生产期间的NPM版本

[英]NPM versions during development and production

From what I have read it is a good idea to use the same version of Node.js throughout the development and production phases of an app. 根据我的阅读,在应用程序的整个开发和生产阶段,最好使用相同版本的Node.js。

Is this also true of NPM? NPM也是这样吗? It looks as if NVM is keeping specific versions of NPM together with specific versions of Node.js inside the .nvm directory. 看起来NVM正在将特定版本的NPM以及特定版本的Node.js保留在.nvm目录中。 However, although I can see from the NVM documentation how to make sure you run an app with a particular version of Node.js, I can not see how to make sure that a particular version of NPM is used for a particular app. 但是,尽管我可以从NVM文档中看到如何确保使用特定版本的Node.js运行应用程序,但是我看不到如何确保特定版本的NPM用于特定应用程序。 For example if I run the command npm install package from the root directory of an app I think it will use the default version of NPM not the specific version associated with the Node.js version specified in the .nvmrc file of the app. 例如,如果我从应用程序的根目录运行命令npm install package ,我认为它将使用NPM的默认版本,而不是与该应用程序的.nvmrc文件中指定的Node.js版本关联的特定版本。

Do I need to be consistent in the version of NPM I use during app development and production? 我需要在应用程序开发和生产过程中使用的NPM版本保持一致吗? If the answer is yes how do I achieve that? 如果答案是肯定的,我该如何实现?

When we start a Project using Nodejs a file named package.json is created automatically and it keeps track of all the dependencies in the ongoing Project. 当我们使用Node.js启动项目时,会自动创建一个名为package.json的文件,它会跟踪正在进行的项目中的所有依赖项。 So you do not need to worry about the versions, you just have to start the project and all the dependencies will be taken care of. 因此,您不必担心版本,只需要启动项目即可解决所有依赖项。 Suppose you need to share your codes(like Git) then you just need to share your codes and package.json file that will do the trick. 假设您需要共享您的代码(例如Git),那么您只需要共享您的代码和将完成此操作的package.json文件即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 npm 本地开发与生产 package 版本 - npm local development vs production package versions npm开发期间的peerDependencies - npm peerDependencies during development 开发和生产中的不同jQuery版本 - Different jQuery versions in development and production NPM生产开发上直播服务器 - NPM production and development on live server `react-hover` npm软件包不在生产版本中,但在开发中运行良好 - `react-hover` npm package not in production build but working fine in development NPM Run Build 始终构建生产而不是开发 - NPM Run Build Always Builds Production and Never Development Python相当于node.js的npm链接使用本地开发版本的需求? - Python equivalent of node.js's npm link to use local development versions of requirements? 我如何专门使用 NPM 本地依赖项进行本地开发,以及使用来自外部注册表的一个依赖项进行生产? - How do I specifically use an NPM local dependency for local development and one from an external registry for production? 打包后节点应用程序(生产和开发模式)的意外行为(npm run dist) - Unexpected behaviour of node app (both production and development mode) after packaging (npm run dist) 如何在开发过程中设置 NPM Typescript 包以维护导入语法? - How to set up a NPM Typescript package during development to maintain import syntax?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM