Cannot find module 'babel-preset-env'
See original GitHub issueI’m submitting a bug report
Webpack Version: 3.12
Babel Core Version: 7.0.0-beta.46 (also “@babel/preset-env”: “^7.0.0-beta.46”)
Babel Loader Version: 8.0.0-beta.2
Please tell us about your environment: Windows 10
Current behavior: Error: “Cannot find module ‘babel-preset-env’ from (root of my project)”
Expected/desired behavior:
use: [{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { modules: false }]
]
}
}]
should load correctly, given the loader and babel versions
- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
Snippet. My config is very basic, otherwise
module: {
rules: [
{
test: /\.js$/,
exclude: resolve('node_modules'),
use: [{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env']
]
}
}]
}
]
}
Webpack being called from a node script in this way:
const webpackConfig = require('./webpack.config.babel')('dev');
function webpackInit() {
const compiler = webpack(webpackConfig);
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
console.log(`compiler has been started`);
if (err || stats.hasErrors()) {
const _err = err ? err : JSON.stringify(stats.toJson('errors-only'));
reject(_err);
}
resolve('webpack has been started');
});
})
.then(resp => console.log(response))
.catch(e => console.error(`Error : ${e}`));
}
-
What is the expected behavior? See above. If this isn’t experienced by anyone else, I will close the issue, but I want to know if anyone is seeing this with the suggested configuration for webpack 3.x | babel-loader 8.x | babel 7.x
-
What is the motivation / use case for changing the behavior? N/A
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:20 (3 by maintainers)
Sounds like you probably have a
.babelrc
that is still referencingbabel-preset-env
.was just
env
fixed the issue