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

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

所以我正在查看 requirejs。我可以使用 npm install requirejs 安装这个包,或者从网站手动下载它。有什么不同?两者都有取舍吗? npm install 只是一种更高级的手动安装方式吗?谢谢。

是的,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

Install the dependencies in the local node_modules folder.

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.

By default, npm install will install all modules listed as dependencies in 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. To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false.

如果没有像 npm 或 yarn 这样的包管理器,你可能会花很多时间来安装东西。当您使用 node js 进行开发时,您需要安装大量的东西。

每种现代编程语言都有自己的包管理器,那么为什么您需要手动安装它们?

假设您在 package.json 中有 10 个库,并且您想一次安装所有这些库,您只需执行“npm i”,它会在大约 10 秒内完成所有工作。与手动安装那10个lib相比,它确实是一个好朋友,可以帮助您立即简化下载lib的过程。