Elhakim
Elhakim

Reputation: 414

Webpack run build & watch ERROR

I was reading a story on medium in an attempt to learn how to use npm and webpack and modern JavaScript. Every thing was great until I installed webpack. I tried to run this command npm run build and npm run watch those scripts exists here in package.json file as

{
  "name": "ebdae",
  "version": "1.0.0",
  "description": "nodescription",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack --progress -p",
    "watch": "webpack --progress --watch"
  },
  "repository": {
    "type": "git",
    "url": "ebdae"
  },
  "author": "elhakim",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-env": "^1.6.1",
    "webpack": "^3.8.1"
  },
  "dependencies": {}
}

But this displayed This Error on command line No configuration file found and no output filename configured via CLI option. A configuration file could be named 'webpack.config.js' in the current directory.

but the config file exists in .bin folder normally and it contains this code:

module.exports = {
  entry: '../../assets/js/index.js',
  output: {
    filename: '../../assets/js/bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      }
    ]
  }
};

and the tree structure as following :

| .git
| assets
    | js
        | index.js
        | bundle.js
| node_modules
    | .bin
        | ...
        | webpack.config.js
| package-lock.json
| package.json

Upvotes: 1

Views: 3817

Answers (1)

Pravesh Khatri
Pravesh Khatri

Reputation: 2244

You have not provide any webpack configuration file in your script.

It should be like this

"build": "webpack --progress -p --config /node_modules/.bin/webpack.config.js"

Upvotes: 3

Related Questions