本文介绍了babel JS 文件无法解析“@babel/runtime/helpers/builtin/classCallCheck"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我删除 node_modules 文件并尝试重新安装 npm 包之前,我的项目运行良好.

on-rest my project was working great untill I delete my node_modules file and try to re-install npm package.

我收到此错误

./node_modules/react-event-listener/dist/react-event-listener.cjs.js
Module not found: Can't resolve '@babel/runtime/helpers/builtin/classCallCheck' in '/Users/suatkarabacak/Desktop/demarkedashboard/node_modules/react-event-listener/dist'

我的 package.json 看起来像这样.

My package.json is looking like this.

{
  "name": "demo",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "admin-on-rest": "^1.4.1",
    "aor-dependent-input": "^1.2.0",
    "aor-parseserver-client": "0.3.0",
    "aor-rich-text-input": "^1.0.1",
    "babel-runtime": "^6.26.0",
    "parse": "^1.11.1",
    "parse-react": "^0.5.2",
    "prop-types": "^15.6.2",
    "react": "^15.6.2",
    "react-dom": "^15.6.2",
    "react-image-lightbox": "^4.6.0",
    "react-images": "^0.5.19"
  },
  "devDependencies": {
    "@babel/runtime": "^7.0.0-beta.56",
    "aor-color-input": "^1.2.1",
    "babel-polyfill": "^6.23.0",
    "react-scripts": "^1.1.4"
  },
  "homepage": "demo.html",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

没有内置文件夹.

可能是什么问题?

推荐答案

由于 Babel 7.x 仍然是 Beta 版本,昨天发布的 beta.56 发生了重大变化.

Since Babel 7.x is still a beta version, there was a breaking change in beta.56, which was released yesterday.

"@babel/runtime": "^7.0.0-beta.56",

如果你使用的是测试版的东西,在你的版本号中使用 ^ 是危险的,因为这意味着它会接受任何最新的版本,无论它是否真的兼容以前的测试版.

If you're using a beta version of something, it is dangerous to use ^ in your version number, because that means it will accept any recent version, whether or not it is actually compatible with previous beta versions.

由于 react-scripts 使用 https://github.com/facebook/create-react-app/blob/1407287839f94151cec729bd89441d4eee7d9dd3/packages/babel-preset-react-app/package.json#L28

"@babel/plugin-transform-runtime": "7.0.0-beta.46",

你应该有

"@babel/runtime": "7.0.0-beta.46",

在您自己的 package.json 中进行匹配.

in your own package.json to match.

这篇关于babel JS 文件无法解析“@babel/runtime/helpers/builtin/classCallCheck"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:54