简体   繁体   中英

Cannot find module 'regenerator-runtime/runtime'

Browserify is throwing this error once I try to use Promises.

Cannot find module 'regenerator-runtime/runtime' in

I've tried node versions 10.15.3 and 12.0.0.

Why is it looking for it in the source folder and not node_modules?

Here's my babel.config.js

module.exports = function (api) {
  api.cache(true);

  const presets = [
    ["@babel/preset-env", {
        "useBuiltIns": "usage",
        "corejs": "2.6.5"
    }

  ]];
  const plugins = [];

  return {
    presets,
    plugins
  };
}

package.json

{
  "name": "ehrsWAR",
  "version": "1.10.15",
  "private": true,
  "scripts": {},
  "browserslist": [
    "> 5%",
    "last 2 versions",
    "Firefox > 20",
    "ie >= 9"
  ],
  "devDependencies": {
    "@babel/cli": "^7.4.3",
    "@babel/core": "^7.4.3",
    "@babel/preset-env": "^7.4.3",
    "@babel/register": "^7.4.0",
    "babelify": "^10.0.0",
    "browserify": "^16.2.3",
    "gulp": "^4.0.0",
    "gulp-rename": "^1.4.0",
    "gulp-streamify": "^1.0.2",
    "gulp-uglify": "^3.0.2",
    "vinyl-buffer": "^1.0.1",
    "vinyl-source-stream": "^2.0.0",
    "watchify": "^3.11.1"
  },
  "browserify": {
    "transform": [
      "babelify"
    ]
  },
  "dependencies": {
    "core-js": "^2.6.5"
  }
}

Try to include "@babel/transform-runtime" in your plugins under babel config. And include @babel/plugin-transform-runtime in your package.json. I was getting the same error and this resolved the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM