我是angular js的新手,我开始创建一个示例项目,比如使用角度种子创建基本模板存储。最初我在安装凉亭组件方面遇到了一些困难,但经过谷歌的一些深入研究后,我会这样做 能够找到解决方案。但现在我陷入了困境。使用bower命令“bower install bootstrap”安装bootstrap之后我使用了boostrap启动模板。在那之后,我无法启动npm。当我试图做“npm start”时, 我收到以下错误:
=============================================== ========================
$ npm start
> angular-seed@0.0.0 prestart C:\project\templatestore
> npm install
> angular-seed@0.0.0 postinstall C:\project\templatestore
> bower install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
> angular-seed@0.0.0 start C:\project\templatestore
> http-server -a localhost -p 8000 -c-1 ./app
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 127.0.0.1:8000
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Deepesh\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v8.9.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-seed@0.0.0 start: `http-server -a localhost -p 8000 -c-1 ./app`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-seed@0.0.0 start script 'http-server -a localhost -p 8000 -c-1 ./app'.
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-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! http-server -a localhost -p 8000 -c-1 ./app
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular-seed
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\project\templatestore\npm-debug.log
=============================================== ========================
我检查了npm-debug.log并收到以下错误:
============= --------------------- ============= ====== ----------------
$ cat 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:\\Users\\UserName\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@3.10.10
3 info using node@v8.9.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle angular-seed@0.0.0~prestart: angular-seed@0.0.0
6 verbose lifecycle angular-seed@0.0.0~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle angular-seed@0.0.0~prestart: PATH: C:\Users\UserName\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\project\templatestore\node_modules\.bin;C:\Users\Deepesh\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Deepesh\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Brackets\command;C:\Program Files\PuTTY;C:\Program Files\nodejs;C:\Ganesh\Scripts;C:\Ganesh;C:\Users\Deepesh\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Deepesh\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
8 verbose lifecycle angular-seed@0.0.0~prestart: CWD: C:\project\templatestore
9 silly lifecycle angular-seed@0.0.0~prestart: Args: [ '/d /s /c', 'npm install' ]
10 silly lifecycle angular-seed@0.0.0~prestart: Returned: code: 0 signal: null
11 info lifecycle angular-seed@0.0.0~start: angular-seed@0.0.0
12 verbose lifecycle angular-seed@0.0.0~start: unsafe-perm in lifecycle true
13 verbose lifecycle angular-seed@0.0.0~start: PATH: C:\Users\UserName\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\project\templatestore\node_modules\.bin;C:\Users\Deepesh\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Deepesh\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Brackets\command;C:\Program Files\PuTTY;C:\Program Files\nodejs;C:\Ganesh\Scripts;C:\Ganesh;C:\Users\Deepesh\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Deepesh\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
14 verbose lifecycle angular-seed@0.0.0~start: CWD: C:\project\templatestore
15 silly lifecycle angular-seed@0.0.0~start: Args: [ '/d /s /c', 'http-server -a localhost -p 8000 -c-1 ./app' ]
16 silly lifecycle angular-seed@0.0.0~start: Returned: code: 1 signal: null
17 info lifecycle angular-seed@0.0.0~start: Failed to exec start script
18 verbose stack Error: angular-seed@0.0.0 start: `http-server -a localhost -p 8000 -c-1 ./app`
18 verbose stack Exit status 1
18 verbose stack at EventEmitter.<anonymous> (C:\Users\UserName\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:255:16)
18 verbose stack at emitTwo (events.js:126:13)
18 verbose stack at EventEmitter.emit (events.js:214:7)
18 verbose stack at ChildProcess.<anonymous> (C:\Users\UserName\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
18 verbose stack at emitTwo (events.js:126:13)
18 verbose stack at ChildProcess.emit (events.js:214:7)
18 verbose stack at maybeClose (internal/child_process.js:925:16)
18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
19 verbose pkgid angular-seed@0.0.0
20 verbose cwd C:\project\templatestore
21 error Windows_NT 10.0.14393
22 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\UserName\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
23 error node v8.9.3
24 error npm v3.10.10
25 error code ELIFECYCLE
26 error angular-seed@0.0.0 start: `http-server -a localhost -p 8000 -c-1 ./app`
26 error Exit status 1
27 error Failed at the angular-seed@0.0.0 start script 'http-server -a localhost -p 8000 -c-1 ./app'.
27 error Make sure you have the latest version of node.js and npm installed.
27 error If you do, this is most likely a problem with the angular-seed package,
27 error not with npm itself.
27 error Tell the author that this fails on your system:
27 error http-server -a localhost -p 8000 -c-1 ./app
27 error You can get information on how to open an issue for this project with:
27 error npm bugs angular-seed
27 error Or if that isn't available, you can get their info via:
27 error npm owner ls angular-seed
27 error There is likely additional logging output above.
28 verbose exit [ 1, true ]
============= --------------------- ============= ====== ----------------
package.json文件:
=======================
{
"name": "angular-seed",
"private": true,
"version": "0.0.0",
"description": "A starter project for AngularJS",
"repository": "https://github.com/angular/angular-seed",
"license": "MIT",
"devDependencies": {
"bower": "^1.7.7",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-firefox-launcher": "^0.1.7",
"karma-jasmine": "^0.3.8",
"karma-junit-reporter": "^0.4.1",
"protractor": "^4.0.9"
},
"scripts": {
"postinstall": "bower install",
"update-deps": "npm update",
"postupdate-deps": "bower update",
"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1 ./app",
"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",
"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor e2e-tests/protractor.conf.js",
"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+' //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
}
}
=======================
index.html文件:
=====================================
<!doctype html>
<html lang="en" ng-app="templateStore">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Template Store</title>
<!-- Bootstrap core CSS -->
<link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="app.css">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#/templates">Template Store</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<main role="main" class="container">
<div ng-view></div>
</main><!-- /.container -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="templates/templates.js"></script>
</body>
</html>
=====================================
控制台中也没有显示错误。 也许有人可以帮助解决问题:)?
答案 0 :(得分:1)
错误:收听EADDRINUSE 127.0.0.1:8000
您的nodeJs可能已在运行或使用此端口。所以打开任务管理器并终止所有nodeJs进程(node.exe)
然后尝试nom start
答案 1 :(得分:0)
这也可能有助于尝试
npm clean cache
然后npm install
然后再次运行服务器