【问题标题】:ng serve fails on Angular 2 created with angular CLI on BoUoWng serve 在 BoUoW 上使用 Angular CLI 创建的 Angular 2 上失败
【发布时间】:2017-07-08 05:18:24
【问题描述】:

我在海拔模式下运行 BoUoW 并安装了 @angular/cli 并使用新命令创建了一个示例项目。

当我尝试通过 npm start 运行应用程序时,它通过说明错误 ng serve failed 而失败,并将其归咎于 npm 和节点版本问题或应用程序本身。 npm 和 node 版本是最新的。

任何 angular 2 专家建议还是我使用了错误的样板应用程序?

编辑:

  1. @angular/cli: 1.0.0-beta.32.3
  2. 节点:6.9.5
  3. npm: 3.10.10

编辑 2:(错误日志)

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@4.1.2
3 info using node@v7.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle testapp@0.0.0~prestart: testapp@0.0.0
6 silly lifecycle testapp@0.0.0~prestart: no script for prestart, continuing
7 info lifecycle testapp@0.0.0~start: testapp@0.0.0
8 verbose lifecycle testapp@0.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle testapp@0.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/mnt/c/Users/sande/Desktop/testapp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
10 verbose lifecycle testapp@0.0.0~start: CWD: /mnt/c/Users/sande/Desktop/testapp
11 silly lifecycle testapp@0.0.0~start: Args: [ '-c', 'ng serve' ]
12 silly lifecycle testapp@0.0.0~start: Returned: code: 1  signal: null
13 info lifecycle testapp@0.0.0~start: Failed to exec start script
14 verbose stack Error: testapp@0.0.0 start: `ng serve`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:192:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:192:7)
14 verbose stack     at maybeClose (internal/child_process.js:890:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid testapp@0.0.0
16 verbose cwd /mnt/c/Users/sande/Desktop/testapp
17 error Linux 3.4.0+
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.5.0
20 error npm  v4.1.2
21 error code ELIFECYCLE
22 error testapp@0.0.0 start: `ng serve`
22 error Exit status 1
23 error Failed at the testapp@0.0.0 start script 'ng serve'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the testapp package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ng serve
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs testapp
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls testapp
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

编辑 3:重现步骤

注意我在 14393.693 / 14.04.5 LTS 上使用 BoUoW

sudo n v7.5.0
npm install -g @angular/cli
ng new my-project
cd my-project
npm start

【问题讨论】:

  • 可以分享一下错误日志吗?
  • 按要求添加了错误日志。对于 npm 6.5.0 的组合,我得到了同样的错误
  • 令人担忧的是,它只有大约 5 行 bash 脚本就搞砸了。我在这里并没有真正做任何特别的事情。
  • 你也可以分享你的 package.json 吗?

标签: node.js angular npm


【解决方案1】:

你有旧版本的 node 和 npm。当前版本是:

节点 - v7.5.0
南 - 4.1.2

请升级并重试。
顺便说一句,使用 Angular CLI,你可以直接 ng 服务。无需使用
npm start。

【讨论】:

  • 这对我不起作用,在我升级到 7.5.0 ng new 后出现错误“npm ERR!找不到模块'internal/fs'”
  • 你升级 node 和 npm 了吗?他们成功了吗?请参阅stackoverflow.com/questions/40663489/…。如果他们成功,那么在你的项目目录中删除 node_modules rm -rf node_modules
    npm install
    ng serve
  • 是的,nodejs 和 npm 安装成功,但是当我尝试通过 npm install 在 7.5.0 / 4.x 上安装依赖项时,它会导致错误找不到模块'internal/fs' 我也是使用 n 在版本之间切换。节点和npm的
猜你喜欢
  • 1970-01-01
  • 2023-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-09
  • 1970-01-01
  • 2020-05-31
  • 2017-11-12
相关资源
最近更新 更多