Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Angular 2本地开发环境在安装后仅运行一次,重复运行_Node.js_Angular_Npm - Fatal编程技术网

Node.js Angular 2本地开发环境在安装后仅运行一次,重复运行

Node.js Angular 2本地开发环境在安装后仅运行一次,重复运行,node.js,angular,npm,Node.js,Angular,Npm,遵循Windows 10上Angular 2的本地开发设置说明,可用于本地开发环境的第一次运行。“npm安装”和“npm启动”都可以正常工作。但是,在关闭所有程序并再次尝试运行“npm start”后,会出现控制台错误和错误日志文件,但浏览器不会打开 我对Angular的quickstart文件进行了三次新的安装/启动,每次都是在上述初始设置后无法运行 其他线程中的解决方案不起作用或不适用,但我将包含package.json的内容,因为前面讨论的一些问题引用了该文件 我按照命令行输出中的说明向“

遵循Windows 10上Angular 2的本地开发设置说明,可用于本地开发环境的第一次运行。“npm安装”和“npm启动”都可以正常工作。但是,在关闭所有程序并再次尝试运行“npm start”后,会出现控制台错误和错误日志文件,但浏览器不会打开

我对Angular的quickstart文件进行了三次新的安装/启动,每次都是在上述初始设置后无法运行

其他线程中的解决方案不起作用或不适用,但我将包含package.json的内容,因为前面讨论的一些问题引用了该文件

我按照命令行输出中的说明向“作者”报告问题,但没有得到响应

位于的“Report issues”链接指示人们在GitHub上提出问题,但GitHub上的管理员在20秒内以其特定格式回复了一篇详细的帖子,并表示要在StackOverflow上发布

我非常感谢在解决方法上的帮助,或者关于如何向有棱角的人报告问题的建议

以下是3项最相关的内容:

命令行:

C:\Users\username\Documents\js\quickstart>npm start

> angular-quickstart@1.0.0 prestart C:\Users\username\Documents\js\quickstart
> npm run build


> angular-quickstart@1.0.0 build C:\Users\username\Documents\js\quickstart
> tsc -p src/

src/app/hero.service.ts(22,2): error TS2393: Duplicate function implementation.
src/app/hero.service.ts(34,2): error TS2393: Duplicate function implementation.

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 build: `tsc -p src/`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 build script 'tsc -p src/'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc -p src/
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\username\Documents\js\quickstart\npm-debug.log

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 prestart: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 prestart script 'npm run build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\username\Documents\js\quickstart\npm-debug.log
npm-debug.log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@3.10.10
3 info using node@v6.9.5
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle angular-quickstart@1.0.0~prestart: angular-quickstart@1.0.0
6 verbose lifecycle angular-quickstart@1.0.0~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle angular-quickstart@1.0.0~prestart: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\username\Documents\js\quickstart\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\nodejs\;C:\Users\username\AppData\Local\Microsoft\WindowsApps;C:\Users\username\AppData\Roaming\npm
8 verbose lifecycle angular-quickstart@1.0.0~prestart: CWD: C:\Users\username\Documents\js\quickstart
9 silly lifecycle angular-quickstart@1.0.0~prestart: Args: [ '/d /s /c', 'npm run build' ]
10 silly lifecycle angular-quickstart@1.0.0~prestart: Returned: code: 1  signal: null
11 info lifecycle angular-quickstart@1.0.0~prestart: Failed to exec prestart script
12 verbose stack Error: angular-quickstart@1.0.0 prestart: `npm run build`
12 verbose stack Exit status 1
12 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
12 verbose stack     at emitTwo (events.js:106:13)
12 verbose stack     at EventEmitter.emit (events.js:191:7)
12 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
12 verbose stack     at emitTwo (events.js:106:13)
12 verbose stack     at ChildProcess.emit (events.js:191:7)
12 verbose stack     at maybeClose (internal/child_process.js:877:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
13 verbose pkgid angular-quickstart@1.0.0
14 verbose cwd C:\Users\username\Documents\js\quickstart
15 error Windows_NT 10.0.14393
16 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
17 error node v6.9.5
18 error npm  v3.10.10
19 error code ELIFECYCLE
20 error angular-quickstart@1.0.0 prestart: `npm run build`
20 error Exit status 1
21 error Failed at the angular-quickstart@1.0.0 prestart script 'npm run build'.
21 error Make sure you have the latest version of node.js and npm installed.
21 error If you do, this is most likely a problem with the angular-quickstart package,
21 error not with npm itself.
21 error Tell the author that this fails on your system:
21 error     npm run build
21 error You can get information on how to open an issue for this project with:
21 error     npm bugs angular-quickstart
21 error Or if that isn't available, you can get their info via:
21 error     npm owner ls angular-quickstart
21 error There is likely additional logging output above.
22 verbose exit [ 1, true ]

我明白了。这些行指出了错误:

src/app/hero.service.ts(22,2): error TS2393: Duplicate function implementation.

src/app/hero.service.ts(34,2): error TS2393: Duplicate function implementation.
修复了hero.service.ts文件中的错误,修复了该问题。令人困惑的是,尽管出现了错误,但在本地开发环境运行时,这些文件仍在工作。该错误仅在重新启动服务器时才明显

在另一个演示文件夹中,出现另一个错误,@NGModule声明数组中缺少逗号。同样的问题也发生了——本地开发环境在仍然打开时没有抱怨,但不会重新启动


这听起来可能是一个缓存问题,对于不熟悉此环境的人来说,缓存问题让人感到困惑。

更基本的答案是使用这样的IDE,它将标记代码中的错误,而不管错误何时发生。VSCode与以下扩展的组合可防止出现本线程中所述的麻烦:

  • 打字英雄
  • 特斯林特
  • 角度2内联

我应该补充一点,仅仅运行“npm安装”和“npm启动”并不能解决“npm启动”不起作用的问题。但是从一个新的快速启动种子开始并运行“npm安装”和“npm启动”确实有效。
src/app/hero.service.ts(22,2): error TS2393: Duplicate function implementation.

src/app/hero.service.ts(34,2): error TS2393: Duplicate function implementation.