npm start给出错误:`output.path`需要是绝对路径或`/`

时间:2017-02-18 06:12:29

标签: javascript node.js reactjs webpack-dev-server

当我使用npm start命令运行我的第一个反应应用程序时,会显示一些错误。请有人帮我解决这个问题。

C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:386
                throw e;
                ^

Error: `output.path` needs to be an absolute path or `/`.
    at Object.setFs (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:88:11)
    at Shared (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:214:8)
    at module.exports (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\middleware.js:22:15)
    at new Server (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\lib\Server.js:56:20)
    at startDevServer (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:379:12)
    at processOptions (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:317:3)
    at Object.<anonymous> (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:441:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! r3@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the r3@1.0.0 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 r3 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 information on how to open an issue for this project with:
npm ERR!     npm bugs r3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls r3
npm ERR! There is likely additional logging output above.

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

1 个答案:

答案 0 :(得分:3)

错误消息很明确:output.path必须是绝对路径或/

你的output.path应该这样写:

var path = require('path');

output: {
    path: path.join( __dirname, './dist/'),

}