Sunday, 12 March 2017

Error: `output.path` needs to be an absolute path or `/`

I am a beginner in React,and at the moment I am trying to do the basic set up. So far I installed the basic modules from npm and the folder structure of my project is as shown below.

folder structure

The package.json shows what I have installed as well as a small description of the project.

{
 "name": "test",
 "version": "1.0.0",
 "description": "test",
 "main": "index.js",
 "scripts": {
   "start": "webpack-dev-server --hot"
},
"repository": {
"type": "git",
"url": "https://github.com/theo82"
},
"keywords": [
"test"
],
"author": "Theo Tziomakas",
"license": "ISC",
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
}
}

Anyway when I am typing npm start,I get this error.

Error: `output.path` needs to be an absolute path or `/`.
at Object.setFs (C:\Users\Theodosios\Desktop\reactApp\node_modules\webpack-d
ev-middleware\lib\Shared.js:88:11)

I believe this has to do with the webpack.config.js file.

 var config = {
 entry: './main.js',

 output: {
  path:'./',
  filename: 'index.js',
 },

 devServer: {
  inline: true,
  port: 3000
 },

 module: {
  loaders: [
     {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',

        query: {
           presets: ['es2015', 'react']
        }
      }
     ]
   }
  }

  module.exports = config;

How can this error be fixed?

Thanks,

Theo?



via Theo

No comments:

Post a Comment