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