简体   繁体   English

如何使 ng new 命令不需要互联网来创建 angular2 项目?

[英]How can I make ng new command not to need an internet to create an angular2 project?

I have an unstable internet connection and I think that is my problem whenever I create a new angular project I get an error or it will take too long to create a new project as well as building it.我的互联网连接不稳定,我认为每当我创建一个新的 angular 项目时,我都会遇到错误,或者创建一个新项目以及构建它需要很长时间。 How can I set up my working environment offline?如何离线设置我的工作环境?

I'm sure that I don't have any problems with my npm and angular\cli since I've tried fixing them having the thought that it was because of versions, missing packages or environment variables.我确信我的 npm 和 angular\cli 没有任何问题,因为我尝试修复它们时认为这是因为版本、缺少包或环境变量。 npm clean cache --force I've done it. npm 清理缓存 --force 我已经完成了。

If you are using the angular CLI you can use:如果您使用的是 angular CLI,您可以使用:

ng new yourProject --skip-install

so you can skip installing all the NPM packages.因此您可以跳过安装所有 NPM 软件包。

EDIT编辑

If you have some old angular project, except for doing ng new yourProject --skip-install you can copy your node_modules to your new project and run npm install while you are offline.如果您有一些旧的 angular 项目,除了执行ng new yourProject --skip-install之外,您可以将node_modules复制到新项目并在离线时运行npm install That way, your new project will be set for ng serve这样,您的新项目将设置为 ng serve

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM