Error running npm run build – webpack@2.4.1

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Error

If the current behavior is a bug, please provide the steps to reproduce.

Running npm run build leads to:

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!

The webpack.config.js

module.exports = {
    entry: ['./app/index.js'],
    output: {
        path: './build',
        filename: 'bundle.js'
    }
}

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Versions:

C:\coding\es6>npm list webpack
es6@1.0.0 C:\coding\es6
`-- webpack@2.4.1
 
C:\coding\es6>node -v
v7.9.0
 
C:\coding\es6>npm -v
4.5.0

Author: Fantashit

1 thought on “Error running npm run build – webpack@2.4.1

  1. Actually the error message tells you everything. The problem isn’t npm run build but an invalid/outdated webpack.config. You are using a relativ path ./build below whereas webpack docs and the message tell you that it must be an absolute path.

    module.exports = {
        entry: ['./app/index.js'],
        output: {
            path: './build',    <== error: this is not an absolute but a relative path
            filename: 'bundle.js'
        }
    }
    

    Maybe this fixes it for you:

    const path = require('path');
    module.exports = {
        entry: ['./app/index.js'],
        output: {
            path: path.resolve(__dirname, './build'),
            filename: 'bundle.js'
        }
    }
    

Comments are closed.