npm install 和 npm run build 有什么区别? [英] What is the difference between npm install and npm run build?
问题描述
npm install
和 npm run build
有什么区别?
我注意到在我的项目中,有时执行 npm install
时 npm 开始失败,但是,在运行 npm run build
后,它工作得很好.
I have noticed in my project that sometimes npm starts failing when npm install
is performed, but, upon running npm run build
, it works just fine.
install
和 run build
这两个目标的内部工作方式有何不同?
How do the inner workings of these two targets namely install
and run build
differ?
推荐答案
npm install
将依赖项安装到 node_modules/
目录中,用于您正在处理的节点项目.您可以在另一个 node.js 项目(模块)上调用 install
,将其安装为您项目的依赖项.
npm install
installs dependencies into the node_modules/
directory, for the node project you're working on. You can call install
on another node.js project (module), to install it as a dependency for your project.
npm run build
什么都不做,除非你指定什么build"在你的 package.json 文件中.它可让您在项目用于其他项目之前为项目执行任何必要的构建/准备任务.
npm run build
does nothing unless you specify what "build" does in your package.json file. It lets you perform any necessary building/prep tasks for your project, prior to it being used in another project.
npm build
是一个内部命令,由 link
和 install
命令调用,根据 构建文档:
npm build
is an internal command and is called by link
and install
commands, according to the documentation for build:
这是 npm link 和 npm install 调用的管道命令.
This is the plumbing command called by npm link and npm install.
您不会正常调用 npm build
,因为它在内部用于使用 node-gyp 构建本机 C/C++ Node 插件.
You will not be calling npm build
normally as it is used internally to build native C/C++ Node addons using node-gyp.
这篇关于npm install 和 npm run build 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!