node.js - Nodejs - Getting Error in babel loader when i initiate npm start -
getting error:
error in multi main module not found: error: cannot resolve module 'react' in c:\users\username\deskto p\reactapp @ multi main
module.exports = config; var config = { entry: './main.js', output: { path:'./', filename: 'index.js', }, devserver: { inline: true, port: 8080 }, module: { loaders: [{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'react', query: { presets: ['es2015', 'react'] } }] } }
node version - 4.4.7
npm version - 3.10.5
babel loaded globally npm install -g babel
npm install -g babel-preset-react
you can try changing loader 'babel'
module.exports = config; var config = { entry: './main.js', output: { path:'./', filename: 'index.js', }, devserver: { inline: true, port: 8080 }, module: { loaders: [{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel', query: { presets: ['es2015', 'react'] } }] } }
this how mine setup , works me.
edit:
this full webpack setup:
module.exports = { entry: [ './src/index.js' ], output: { path: __dirname, publicpath: '/', filename: 'bundle.js' }, module: { loaders: [{ exclude: /node_modules/, loader: 'babel', query: { presets: ['react', 'es2015', 'stage-1'] } },{ include: /\.json$/, loaders: ["json-loader"] },{ test: /(\.css)$/, loaders: ['style', 'css'] }] }, resolve: { extensions: ['', '.json', '.js', '.jsx'] }, devserver: { historyapifallback: true, contentbase: './' } };
with following dependencies relate babel , webpack (not full list)
"devdependencies": { "babel-core": "^6.2.1", "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.1.18", "babel-preset-react": "^6.1.18", "webpack": "^1.12.9", "webpack-dev-server": "^1.14.0" }, "dependencies": { "babel-preset-stage-1": "^6.1.18", "json-loader": "^0.5.4", }
Comments
Post a Comment