sprewell20051116 / JavascriptCourse

讀書會提出問題的平台
0 stars 2 forks source link

Subject04 - Setting up with webpack #5

Open sprewell20051116 opened 7 years ago

sprewell20051116 commented 7 years ago

$npm run build Error

GIGIGUNdeMacBook-Pro:es6 GIGIGUN$ npm run build
> es6@1.0.0 build /Users/GIGIGUN/es6
> webpack

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.path: The provided value "./build" is not an absolute path!

npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! es6@1.0.0 build: `webpack`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the es6@1.0.0 build script 'webpack'.
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 es6 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs es6
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls es6
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/GIGIGUN/es6/npm-debug.log
sprewell20051116 commented 7 years ago

ref : https://stackoverflow.com/questions/43028487/invalid-configuration-object-output-path-is-not-an-absolute-path

最關鍵的錯誤應該是 - configuration.output.path: The provided value "./build" is not an absolute path!

所以嘗試去修改 webpack.config.js

改成

+ const path = require('path');

module.exports = {
  entry: ['babel-polyfill', './app/index.js'],
  output: {
-    path: './build',
+    path: path.resolve(__dirname, 'build'),     // if the above line does not work, try `path: __dirname + '/build'`
    filename: 'bundle.js'
  }
}