Reputation: 1722
Here's my webpack-dev-server configuations
module.exports = {
entry: './main.js',
output: {
path: './',
filename: 'bundle.js'
},
devServer: {
inline: true,
port: 9000
},
module: {
loaders: [{
test: /\.js$/,
exclude: '/(node_modules)/',
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}]
}
};
Why would I get the following error when I run the server
ERROR in (webpack)-dev-server/~/strip-ansi/index.js Module build failed: Error: Couldn't find preset "react" relative to directory "/Users/ecco/.nvm/versions/node/v5.4.0/lib/node_modules/webpack-dev-server/node_modules/strip-ansi"
my package.json
"devDependencies": {
"babel-core": "^6.4.5",
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"webpack": "^1.12.13"
}
Upvotes: 0
Views: 756
Reputation: 1036
You don't appear to have the webpack-dev-server
installed as a local node module (it's not in your package.json
You can see which modules are installed locally and globally with npm list
and npm list --global
. To look for specific modules, pipe that command into grep
i.e. npm list --global | grep webpack-dev-server
I'd suggest installing the dev server as a devDependency of your project. As a general rule, try to avoid installing modules with -g
unless absolutely necessary. Also, use npm
scripts (in your package.json) to run modules in your local directory, without having to reference them explicitly e.g.
{
"scripts": {
"serve": "webpack-dev-server --config your.config.js"
}
}
then run npm run serve
rather than running ./node_modules/.bin/webpack-dev-server --config your.config.js
(or worse, installing it globally)
Upvotes: 1