angular 2示例webpack项目无法加载webpack-dev-server

时间:2017-09-14 12:46:21

标签: angular webpack webpack-dev-server

我正在尝试运行由角色权威机构提供的项目 here

下载后,我运行 npm install 。然后我尝试使用 npm start 运行服务器。但不知何故,它给了我以下错误:

                                              Asset       Size  Chunks                    Chunk Names
assets/angular.72e938844d7d3f68edf83a97e34f0859.png    4.45 kB          [emitted]
                     vendor.23469b081171ef5c7a6b.js    1.01 MB       0  [emitted]  [big]  vendor
                        app.23469b081171ef5c7a6b.js    1.87 kB       1  [emitted]         app
                  polyfills.23469b081171ef5c7a6b.js     117 kB       2  [emitted]         polyfills
                       app.23469b081171ef5c7a6b.css  107 bytes       1  [emitted]         app
                   app.23469b081171ef5c7a6b.css.map  312 bytes       1  [emitted]         app
                                         index.html  555 bytes          [emitted]
  [23] ./~/@angular/core/@angular/core.es5.js 490 kB {0} [built]
  [58] ./~/@angular/platform-browser/@angular/platform-browser.es5.js 141 kB {0} [built]
  [71] ./~/@angular/common/@angular/common.es5.js 132 kB {0} [built]
  [92] ./~/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js 5.88 kB {0} [built]
 [193] ./~/@angular/http/@angular/http.es5.js 74.6 kB {0} [built]
 [194] ./~/@angular/router/@angular/router.es5.js 220 kB {0} [built]
 [195] ./src/app/app.module.ts 1.22 kB {1} [built]
 [196] ./~/core-js/es6/index.js 5.88 kB {2} [built]
 [197] ./~/core-js/es7/reflect.js 510 bytes {2} [built]
 [198] ./~/rxjs/Rx.js 9.65 kB {0} [built]
 [199] ./~/zone.js/dist/zone.js 119 kB {2} [built]
 [318] ./~/core-js/modules/es6.string.fixed.js 189 bytes {2} [built]
 [631] ./src/main.ts 416 bytes {1} [built]
 [632] ./src/polyfills.ts 365 bytes {2} [built]
 [633] ./src/vendor.ts 416 bytes {0} [built]
    + 622 hidden modules
Child html-webpack-plugin for "index.html":
       [0] ./~/html-webpack-plugin/lib/loader.js!./src/index.html 301 bytes {0} [built]
Child extract-text-webpack-plugin:
       [0] ./~/css-loader/lib/css-base.js 1.46 kB {0} [built]
       [1] ./~/css-loader?sourceMap!./src/assets/css/styles.css 463 bytes {0} [built]

> angular-io-example@1.0.0 start C:\Users\anand\webpack
> webpack-dev-server --inline --progress --port 8080

 10% building modules 3/3 modules 0 activeevents.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES 127.0.0.1:8080
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1244:19)
    at listen (net.js:1293:10)
    at net.js:1403:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)

npm ERR! Windows_NT 10.0.15063
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.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular-io-example@1.0.0 start: `webpack-dev-server --inline --progress --port 8080`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-io-example@1.0.0 start script 'webpack-dev-server --inline --progress --port 8080'.
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-io-example package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server --inline --progress --port 8080
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-io-example
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-io-example
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\anand\webpack\npm-debug.log

我的本​​地机器或其他什么问题?

1 个答案:

答案 0 :(得分:1)

在本地计算机上运行端口8080上的其他内容,请更改package.json文件端口

"scripts": {
"start": "webpack-dev-server --inline --progress --port 4200",
"test": "karma start", ...