3

只是为了澄清这一点:我对 AngularJS和任何 Web 技术都是全新的。我是 Web 开发的初学者。

我尝试安装它,但我不得不承认,在多次“未知按钮按下”之后,我可能搞得一团糟,也可能没有。

我按照AngularJS 网站的教程安装 Angular,然后我只想按下“红色按钮”:

npm start

但它抛出了一个错误说:

Angular JS - npm start/ng serve 错误


实际的 Debug_Log 在这里:

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

因此,我在 Google Globe 中进行了搜索,但一无所获。

另外,我不知道这是否相关,但在我的 TypeScript 代码中:

import { View, Component } from '@angular2/core';
[... Components Here ... ]

它抛出一个错误:

Cannot find module '@angular2/core'

如果有人能启发我,那将让我很高兴!

4

2 回答 2

1

如果您刚刚开始 angular 2,请按照 angular 网站上提到的这些步骤进行操作。

1 从这里下载启动项目。将其保存到本地文件夹,比如说 c:\test\ 。location = https://github.com/angular/quickstart.git quickstart 这就是你需要为 hellp world app 做的所有事情。

2) 转到命令提示符然后 cd c:\test 。3)如果没有安装请insatll node js。4) npm 安装 5) npm 启动

这将显示您的第一个 angular 2 hello world 应用程序。

这个站点最好学习 angular 2 。 https://angular.io/docs/ts/latest/guide/setup.html

于 2017-01-22T14:34:31.490 回答
0

这有点奇怪,但根文件夹应该像这种模式一样命名,my-app, tour-of-heroes。

今天早些时候我遇到了这个问题,像这样错误地复制了 my-app: sudo cp -rv my-app tourOfHeroes 然后在 tourOfHeroes 中运行 npm start 得到那个错误

然后几个小时后决定这样做: sudo cp -rv my-app tour-of-heroes 然后在英雄之旅中运行 npm start 然后像魔术一样运行,我又恢复了业务

于 2017-10-29T08:37:15.027 回答