2015-12-24 60 views
2

我正在嘗試學習如何設置我的開發環境,並從https://egghead.io/lessons/react-react-fundamentals-development-environment-setup?series=react-fundamentals開始瞭解egghead的視頻教程。然而,在第一視頻提到的安裝相關的模塊後,當我嘗試NPM開始,它拋出以下錯誤:我的npm開始反應教程項目不起作用

Shaileshs-MacBook-Pro:react-project shailesh$ npm start 

> [email protected] start /Users/shaileshgupta/react-project 
> webpack-dev-server 

/Users/shaileshgupta/react-project/webpack.config.js:3 
    output: { 
    ^^^^^^ 

SyntaxError: Unexpected identifier 
    at exports.runInThisContext (vm.js:53:16) 
    at Module._compile (module.js:374:25) 
    at Object.Module._extensions..js (module.js:405:10) 
    at Module.load (module.js:344:32) 
    at Function.Module._load (module.js:301:12) 
    at Module.require (module.js:354:17) 
    at require (internal/module.js:12:17) 
    at module.exports (/Users/shaileshgupta/react-project/node_modules/webpack/bin/convert-argv.js:80:13) 
    at Object.<anonymous> (/Users/shaileshgupta/react-project/node_modules/webpack-dev-server/bin/webpack-dev-server.js:55:48) 
    at Module._compile (module.js:398:26) 

npm ERR! Darwin 15.0.0 
npm ERR! argv "/usr/local/Cellar/node/5.3.0/bin/node" "/usr/local/bin/npm" "start" 
npm ERR! node v5.3.0 
npm ERR! npm v3.3.12 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `webpack-dev-server` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'webpack-dev-server'. 
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 shaileshgupta package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  webpack-dev-server 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls shaileshgupta 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Users/shaileshgupta/react-project/npm-debug.log 

我撞我的頭,並試圖調試它,但無法找到任何可能的解決方案到它。任何人都可以幫助我理解這裏發生了什麼?如果您需要更多信息,請與我們聯繫。

+1

發佈您的整個webpack.config.js文件 – devwannabe

回答

1

後整個代碼,你可能module.exports對象的第一個屬性後缺少一個逗號

3

您可能需要安裝的WebPack開發服務器

npm install webpack-dev-server --save-dev 
0

如果你有一個文件與.jsx擴展名,請嘗試將其更改爲.js。當我遇到同樣的問題時,這對我有用。

0

大多數時候我們會複製粘貼webpack.config.js文件的教程。代碼的一部分在webpack.config.js中看起來像這樣。

devServer: { 
    inline: true, 
    port: 8080 } 

當您從您可能還沒有安裝webpack-dev-server命令提示符npm start。如果這樣運行下面的線

npm install webpack-dev-server -g 

在少數情況下webpack-dev-server已安裝,但別的東西會在8080主機上運行。
在這種情況下,只需更改webpack.config.js文件中的端口號。下面是更新的代碼。

devServer: { 
    inline: true, 
    port: 4000 } 

這應該可以解決您的問題。

Click here for more about this issue