简体   繁体   English

为什么每次创建一个新的angular 2项目时都必须运行npm install?

[英]Why Do I have to run npm install everytime I create a new angular 2 project?

每次我创建一个新的angular 2项目时,它说“node_modules显示为空,你可能需要运行`npm install”

Dependencies 依赖

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 installNode 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.

相关问题 为什么在我的 angular 项目中安装 npm 时出现此错误? - Why do I get this error on npm install in my angular project? 每次运行 Angular 时,SSL 都会出现问题,这是为什么? - Everytime I run Angular I have a problem with the SSL why is that? 为什么在 macOS Catalina 上尝试为 Angular 项目运行 npm install 时会出现这些故障? - Why am I getting these failures when trying to run npm install for an Angular project on macOS Catalina? 每次我尝试运行 NPM 安装终端都会抛出几个错误 - Everytime I Try To Run NPM Install Terminal throws several errors 我在安装 angular 和 npm 包时出错 - i have error install angular and npm package 我无法安装角度项目:npm install -g @ angular / cli - I can not install angular project: npm install -g @angular/cli 如何使用 NPM 安装 Angular 2? - How do I install Angular 2 using NPM? 如何删除漏洞,每次我运行命令 npm install highcharts --save - How can I remove vulnerabilities, everytime I run the command npm install highcharts --save 当我在 angular 项目中安装 npm 时创建/修改了哪些文件? (在我的情况下 angular 8) - which files are created/modified when I do npm install in an angular project? (in my case angular 8) 我是角度2的新手,我在尝试npm install以下错误时安装了节点v5和npm v3 - i m new to angular 2 i have installed node v5 and npm v3 while trying npm install following error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM