babel: [Bug]: Babel @babel/preset-env cannot find module 'regjsgen'
💻
- Would you like to work on a fix?
How are you using Babel?
Input code
rollup.config.js:
`import resolve from ‘@rollup/plugin-node-resolve’; import babel from ‘@rollup/plugin-babel’;
export default { input: ‘assets/source/scripts/main.js’, output: { file: ‘assets/build/scripts/main.js’, format: ‘iife’, }, plugins: [ resolve(), babel({ babelHelpers: ‘bundled’ }) ] };`
assets/source/scripts/main.js
Does not matter if this file is empty or has code. The error is always as follows.
`# yarn build yarn run v1.22.10 $ rollup --config
assets/source/scripts/main.js → assets/build/scripts/main.js… [!] (plugin babel) Error: [BABEL] C:\Local Sites\assets\source\scripts\main.js: Cannot find module ‘regjsgen’ Require stack:
- C:\Local Sites\node_modules\regexpu-core\rewrite-pattern.js
- C:\Local Sites\node_modules@babel\helper-create-regexp-features-plugin\lib\index.js
- C:\Local Sites\node_modules@babel\plugin-transform-dotall-regex\lib\index.js
- C:\Local Sites\node_modules@babel\preset-env\lib\available-plugins.js
- C:\Local Sites\node_modules@babel\preset-env\lib\filter-items.js
- C:\Local Sites\node_modules@babel\preset-env\lib\index.js
- C:\Local Sites\node_modules@babel\core\lib\config\files\module-types.js
- C:\Local Sites\node_modules@babel\core\lib\config\files\configuration.js
- C:\Local Sites\node_modules@babel\core\lib\config\files\index.js
- C:\Local Sites\node_modules@babel\core\lib\index.js
- C:\Local Sites\node_modules@rollup\plugin-babel\dist\index.js
- C:\Local Sites\rollup.config.js
- C:\Local Sites\node_modules\rollup\dist\shared\loadConfigFile.js
- C:\Local Sites\node_modules\rollup\dist\bin\rollup (While processing: “C:\Local Sites\node_modules\@babel\preset-env\lib\index.js”)`
=======
Configuration file name
package.json
Configuration
{ “name”: “whatever”, “version”: “0.0.3963”, “description”: “Theme”, “engines”: { “node”: “>=10.0.0”, “npm”: “>=6.0.0” }, “scripts”: { “build”: “rollup --config” }, “dependencies”: { “bootstrap-sass”: “^3.4.1”, “jquery”: “^3.5.1” }, “devDependencies”: { “@babel/core”: “7.14.2”, “@babel/plugin-transform-classes”: “^7.14.2”, “@babel/preset-env”: “7.14.2”, “@rollup/plugin-babel”: “^5.3.0”, “@rollup/plugin-node-resolve”: “^13.0.0”, “autoprefixer”: “^10.2.5”, “browserslist”: “^4.16.6”, “chalk”: “^4.1.0”, “del”: “^6.0.0”, “fancy-log”: “^1.3.3”, “graceful-fs”: “^4.2.2”, “gulp”: “^4.0.2”, “gulp-bump”: “^3.2.0”, “gulp-clean-css”: “^4.2.0”, “gulp-concat”: “^2.5.2”, “gulp-image”: “^6.2.1”, “gulp-plumber”: “^1.2.1”, “gulp-postcss”: “^9.0.0”, “gulp-real-favicon”: “^0.3.2”, “gulp-sass”: “^4.0.2”, “gulp-sourcemaps”: “^3.0.0”, “merge-stream”: “^2.0.0”, “postcss”: “^8.2.15”, “rollup”: “^2.47.0” }, “babel”: { “presets”: [ “@babel/preset-env”, { “targets”: { “browsers”: [ “last 2 versions”, “not ie <= 10” ] }, “useBuiltIns”: “entry”, “debug”: true, “exclude”: “node_modules/**” } ], “plugins”: [ “@babel/plugin-transform-classes” ] } }
Current and expected behavior
I am trying to retire my Gulp tasks and move them over to Rollup.
I am having issues with @babel/preset-env. If I include it as a preset with or without any option config, I get an error. The babel plugins run fine without the @babel/preset-env added to preset.
I have no idea why I am getting a “Cannot find module ‘regjsgen’” error because I do not use regjsgen anywhere in my code.
The expected behaviour is the code should transpile with @babel/preset-env preset.
Environment
Yarn 1.22.10 Node 14.16.1 Babel 7.14.2 Rollup 2.47.0 Windows 10
Possible solution
No response
Additional context
Just for the record, the package.json config below works without @babel/preset-env added to the babel preset.
{ "name": "whatever", "version": "0.0.3963", "description": "Theme", "engines": { "node": ">=10.0.0", "npm": ">=6.0.0" }, "scripts": { "build": "rollup --config" }, "dependencies": { "bootstrap-sass": "^3.4.1", "jquery": "^3.5.1" }, "devDependencies": { "@babel/core": "7.14.2", "@babel/plugin-transform-classes": "^7.14.2", "@babel/preset-env": "7.14.2", "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-node-resolve": "^13.0.0", "autoprefixer": "^10.2.5", "browserslist": "^4.16.6", "chalk": "^4.1.0", "del": "^6.0.0", "fancy-log": "^1.3.3", "graceful-fs": "^4.2.2", "gulp": "^4.0.2", "gulp-bump": "^3.2.0", "gulp-clean-css": "^4.2.0", "gulp-concat": "^2.5.2", "gulp-image": "^6.2.1", "gulp-plumber": "^1.2.1", "gulp-postcss": "^9.0.0", "gulp-real-favicon": "^0.3.2", "gulp-sass": "^4.0.2", "gulp-sourcemaps": "^3.0.0", "merge-stream": "^2.0.0", "postcss": "^8.2.15", "rollup": "^2.47.0" }, "babel": { "plugins": [ "@babel/plugin-transform-classes" ] } }
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (7 by maintainers)
As you can see the package.json of
regjsgen
is corrupted, they should look like https://unpkg.com/regjsgen@0.5.2/package.json, you can try removingnode_modules/regjsgen
and re-install, or try to download the tarball shown innpm view regjsgen dist.tarball
and extract for yourself to see what is going wrong here.