[英]Why Do I have to run npm install everytime I create a new angular 2 project?
每次我创建一个新的angular 2项目时,它说“node_modules显示为空,你可能需要运行`npm install”
In your angular project, you have a file called package.json
. 在角度项目中,您有一个名为
package.json
的文件。 this file is responsible for holding track of your projects dependencies . 此文件负责跟踪项目依赖项 。
When you run npm install
, Node Package Manager , or npm for short, will download those dependencies and put them in node_modules
folder. 运行
npm install
, Node Package Manager或简称npm时 ,将下载这些依赖项并将它们放在node_modules
文件夹中。
You need to run npm install to install the dependencies. 您需要运行npm install来安装依赖项。 May be refer to https://docs.npmjs.com/cli/install .
可以参考https://docs.npmjs.com/cli/install 。
Consider using the Angular CLI to build your application instead. 请考虑使用Angular CLI来构建应用程序。 Then you won't need to use
npm install
when building a new application. 然后,在构建新应用程序时,您不需要使用
npm install
。
See this for more information: https://github.com/angular/angular-cli/wiki 有关更多信息,请参阅此处 : https : //github.com/angular/angular-cli/wiki
Once you run the ng new my-project
. 一旦你运行了
ng new my-project
。 Just give it some time to install the dependencies into the node_modules folder, which shows the below message. 只需给它一些时间将依赖项安装到node_modules文件夹中,该文件夹显示以下消息。
Installing packages for tooling via npm 通过npm安装工具包
You will get the following message once it is done: 完成后,您将收到以下消息:
Installed packages for tooling via npm. 通过npm安装工具包。 Project 'my-project' successfully created.
项目'my-project'已成功创建。
Now try running the ng serve
. 现在尝试运行
ng serve
。 It should work fine. 它应该工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.