2017-04-12 130 views
-2
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. 
- configuration.output.path: The provided value "" is not an absolute path! 
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! [email protected] start: `webpack-dev-server --hot` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'webpack-dev-server --hot'. 
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 helloworldapp package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  webpack-dev-server --hot 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs helloworldapp 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls helloworldapp 
npm ERR! There is likely additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /home/aakash/.npm/_logs/2017-04-12T09_51_55_188Z-debug.log 
+1

錯誤消息非常明確 - 配置文件中的'output.path'沒有設置。 –

+0

我正在從[https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.html]進行環境設置。 我已經創建了與上述相同的文件夾結構,但是我正在獲取上面的configuration.output.path錯誤 –

+0

該鏈接不存在 - 您拼錯了嗎?無論採用哪種方式,您都應該將「webpack.config.js」添加到問題中,因爲這絕對是問題所在。 –

回答

0

隨着錯誤消息指出:

configuration.output.path: The provided value "" is not an absolute path! 

爲什麼多數民衆贊成顯示一個空字符串,而不是output.path實際價值,我不知道 - 但無論哪種方式,你的配置是錯誤的。 output.path的值具有爲絕對路徑,並且您將其設置爲相對路徑。

通常的方法周圍的人這得到的是從節點導入path模塊,並使用path.join,就像這樣:

var path = require('path'); 

module.exports = { 
    /// ... 

    output: { 
     path: path.resolve(__dirname, "dist"), 
     filename: "index.js" 
    }, 

    // ... 
}; 

但是,因爲你只是一味以輸出文件的根目錄中,你可以這樣做:

// no path import needed 

module.exports = { 
    // ... 

    output: { 
     path: __dirname, 
     filename: "index.js" 
    }, 

    // ... 
};