如何修复错误找不到模块'core-js / es6'

时间:2019-08-16 16:32:28

标签: mongodb babel

无论我做什么,我都一直出现错误。实际上,我正在使用mongoose和babel-watch将mongoDB作为服务器构建应用程序,但是每次运行babel-watch时,都会出现此错误:

  

Error cannot find module 'core-js/es6'

我已经使用core.js安装并重新安装了npm install core.js,但是没有任何变化。请帮忙。

这些是我在项目中安装的依赖项:

"dependencies": {
    "body-parser": "^1.19.0",
    "core-js": "^2.6",
    "cuid": "^2.1.6",
    "express": "^4.17.1",
    "limax": "^1.7.0",
    "mongoose": "^5.6.9",
    "node-gyp": "^5.0.3"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.6",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-watch": "^7.0.0",
    "nodemon": "^1.19.1"
  }
}

Code error seen from terminal after running npm start

2 个答案:

答案 0 :(得分:1)

对于在 App.tsx 中导入 core.js v3.9 的下一行:import "core-js/es";

答案 1 :(得分:0)

鉴于您正在使用core-js v2.6.9,因此路径应为core-js/library/es6,如示例here在文档中所示。