将ES6中的npm软件包转换为codesandbox中的common,错误消息毫无价值吗?

问题描述

我正在尝试使用npm中用ES6编写的codesandBox中的组件

我设法按预期方式看到了该组件,但是在控制台中仍然有很多错误,声称它不了解React组件(例如<Main>

Error when converting '/node_modules/...' esmodule to commonjs: [9:5]: Unexpected token: '<' 

这是我的package.json

{
  "name": "blocks","version": "1.0.0","description": "","keywords": [],"main": "src/index.js","dependencies": {
    "aES6component": "0.0.1","react": "16.12.0","react-dom": "16.12.0","react-scripts": "3.0.1"
  },"devDependencies": {
    "@babel/cli": "7.10.5","@babel/plugin-transform-modules-commonjs": "7.10.4","@babel/preset-react": "7.10.4","babel-core": "6.26.3"
  },"scripts": {
    "start": "react-scripts start","build": "react-scripts build","test": "react-scripts test --env=jsdom","eject": "react-scripts eject"
  },"browserslist": [
    ">0.2%","not dead","not ie <= 11","not op_mini all"
  ]
}

这是我的babel.config.json

{
  "presets": ["@babel/preset-react"],"plugins": ["@babel/plugin-transform-modules-commonjs"]
}

为什么我会收到这些消息,为什么尽管有这些消息我仍按预期方式渲染组件?


我马上就得到了错误,然后您可以看到转码模块的图标,然后我看到正确的渲染,就像错误是否过早并且不适用于最终版本(但仍然存在)

这是预期的行为吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)