angularjs - 无法使用 ng new 命令创建项目

标签 angularjs node.js

我正在尝试使用命令创建一个 Angular 项目

ng new my

创作开始,但在某个时刻卡住了,永远不会结束。我得到以下终端输出,

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
installing ng2
  create .editorconfig
  create README.md
  create src/app/app.component.css
  create src/app/app.component.html
  create src/app/app.component.spec.ts
  create src/app/app.component.ts
  create src/app/app.module.ts
  create src/app/index.ts
  create src/app/shared/index.ts
  create src/assets/.gitkeep
  create src/assets/.npmignore
  create src/environments/environment.prod.ts
  create src/environments/environment.ts
  create src/favicon.ico
  create src/index.html
  create src/main.ts
  create src/polyfills.ts
  create src/styles.css
  create src/test.ts
  create src/tsconfig.json
  create src/typings.d.ts
  create angular-cli.json
  create e2e/app.e2e-spec.ts
  create e2e/app.po.ts
  create e2e/tsconfig.json
  create .gitignore
  create karma.conf.js
  create package.json
  create protractor.conf.js
  create tslint.json
Successfully initialized git.
Installing packages for tooling via npm.

在最后一行之后,它就永远停止了,我在提供了 10 分钟的时间后就退出了。尽管文件已正确生成,但当我运行 ng server 时,我收到错误,

1st time: it count find the portfinder 
2nd time:  module.js:327
    throw err;
    ^
Error: Cannot find module 'ember-cli/lib/cli'

我认为我需要提供更多时间来安装工具包或者还有其他事情。这是我第一次使用 Angular,因此对这个问题有点困惑。谢谢。

EDIT:

我再次尝试并等待足够长的时间才收到以下错误消息,

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.6.0
npm ERR! npm  v2.15.9
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @angular/compiler@2.1.0 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/compiler-cli@0.6.4 wants @angular/compiler@2.0.2
npm ERR! peerinvalid Peer @angular/platform-server@2.1.0 wants @angular/compiler@2.1.0

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Chaklader/Desktop/my/npm-debug.log

Package install failed, see above.

我应该怎么做才能解决这个问题?

最佳答案

您可以按照以下步骤解决您的问题:

  1. 在旧版本的 angular-cli 中,您只需使用 ng new App --skip-npm 以避免安装。对于最新版本,您可以使用 ng new App --skip-install 代替;
  2. 使用cd App进入目录,然后通过npm install安装npm。
  3. 等待几分钟以完成安装。使用 CLI,以下是如何编译和运行它 ngserve

我引用这个solution-angular-ng-new-command-stuck-at-installing-packages-for-tooling-via-npm解决了这个问题.

关于angularjs - 无法使用 ng new 命令创建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40046489/

相关文章:

node.js - Nodejs 应用程序中强制使用 NPM 版本

css - md-datepicker 没有正确呈现日历

javascript - 尽管调用清除函数,JQuery 数据表行仍不删除

java - 如何将跨源资源共享与 Spring MVC 4.0.0 RESTful Webservice 集成

javascript - 什么是最有效的 node.js 进程间通信库/方法?

node.js - node-orm2 中的引用键

javascript - 由 ng-options 填充的下拉列表需要滚动条

javascript - 仅在第一次更新模糊

javascript - 如何在azure网站子目录中运行node.js应用程序

windows - 专为 Unix 设计的 Node.js 模块?