问题描述
刚刚重新安装了Angular并使用ng new开始了一个新项目,但是在我制作新项目并cd进入后我无法执行ng serve.在我新建一个新项目后,在我的 Mac Mini 中,我可以直接进入项目文件夹并执行 ng serve,在我的 Windows 10 中,我需要先执行 npm install 因为直接 ng serve 给了我错误.
Just re-installed Angular and started a new project using ng new, but I couldn't execute ng serve after I made the new project and cd into it. In my Mac Mini after I ng new a new project, I can just cd into the project folder and do ng serve, in my Windows 10 I need to execute npm install first cause straight ng serve gave me error.
我检查了项目文件夹后,这是因为 ng new 并没有在新项目中创建 node_moodules 并下载所有需要的包(ng new 执行得非常快).
After I checked the project folder, its because ng new doesn't make a node_moodules in the new project and download all the required packages ( ng new executed very fast ).
根据文档和大多数设置指南,在 ng new 之后,我们可以在将目录更改为项目目录后直接进入 ng serve.我的安装有问题(Node、angular、npm 等...)还是正常?
Based on the documentation and most setup guides out there, after ng new we can go straightly to ng serve after change the directory to the project directory. Is there something wrong with my installation ( Node, angular, npm, etc... ) or this is normal ?
https://angular.io/guide/quickstart
我在 Windows 10 中使用 Angular CLI 1.2.1,在 OSX 中使用 Angular CLI 1.2.0.
I use Angular CLI 1.2.1 in the Windows 10 and Angular CLI 1.2.0 in OSX.
推荐答案
我正在使用 Angular 2 并且遇到同样的问题那里的每个人都试图通过建议适用于以前版本或 AngularJS 的解决方案来解决这个问题
I am doing Angular 2 and having the same issuesEveryone out there is trying to solve the issue by suggesting solutions that worked with previous versions or maybe AngularJS
确实,每次创建新项目时都必须执行 npm install,因为这会创建 node_modules 文件夹
Its true you have to do npm install every time you create a new project because that creates the node_modules folder
这篇关于Angular 4,ng new 不在项目目录中创建 node_modules?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!