简体   繁体   English

npm install 和手动安装有什么区别?

[英]What's the difference between npm install and manual installation?

So i'm looking at requirejs.所以我在看requirejs。 I can either install this package with npm install requirejs, or download it manually from the website.我可以使用 npm install requirejs 安装这个包,也可以从网站上手动下载。 What's the difference?有什么不同? Are there tradeoffs to either one?两者是否有取舍? Is npm install just a fancier way of manually installing? npm install 只是一种更高级的手动安装方式吗? Thanks.谢谢。

Yes, npm install is just a fancier way to add package that help saving your precious time.是的,npm install 只是一种添加包的更巧妙的方式,可以帮助您节省宝贵的时间。

Base on the description here: npm install .基于此处的描述: npm install

If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that如果包有 package-lock,或者 npm shrinkwrap 文件,或者 yarn lock 文件,依赖的安装会由那个驱动

Install the dependencies in the local node_modules folder.在本地 node_modules 文件夹中安装依赖项。

In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.在全局模式下(即在命令后附加 -g 或 --global),它将当前包上下文(即当前工作目录)安装为全局包。

By default, npm install will install all modules listed as dependencies in package.json.默认情况下,npm install 将安装 package.json 中列为依赖项的所有模块。

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.使用 --production 标志(或当 NODE_ENV 环境变量设置为生产时),npm 将不会安装 devDependencies 中列出的模块。 To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false.要在 NODE_ENV 环境变量设置为生产时安装依赖项和 devDependencies 中列出的所有模块,您可以使用 --production=false。

Without a package manager like npm or yarn, it could take you a lot of time just for installing stuff.如果没有像 npm 或 yarn 这样的包管理器,安装东西可能会花费你很多时间。 And while you are developing with node js, you'd have ton of things to install.当您使用 node js 进行开发时,您需要安装大量的东西。

Every modern programming language has it's own package manager, so why you ever need to manually install them?每一种现代编程语言都有自己的包管理器,那么为什么你需要手动安装它们呢?

imagine you have 10 libraries in package.json, and you want to install all of them at once, you can just do "npm i" and it will take care of all, in just ~10sec.假设您在 package.json 中有 10 个库,并且您想一次安装所有这些库,您可以执行“npm i”,它会在大约 10 秒内处理所有问题。 compare this with installing those 10 lib manually, it is indeed a good friend, to help you ease the process of downloading lib for you in no time.与手动安装这10个lib相比,它确实是一个好朋友,可以帮助您立即为您简化下载lib的过程。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM