简体   繁体   English

npm package babel 错误在我自己的 package

[英]npm package babel error in my own package

I have created my own npm package but while using in a test application am getting the following error: Add @babel/plugin-transform-react-jsx to the 'plugins' section of your Babel config to enable transformation.我已经创建了自己的 npm package 但在测试应用程序中使用时出现以下错误:将@babel/plugin-transform-react-jsx 添加到 Babel 配置的“插件”部分以启用转换。

Note: I've written my component in JSX注意:我已经用 JSX 编写了我的组件

package.json package.json

{
      "name": "my-test-package",
      "version": "1.4.3",
      "description": "Rich form fieds with simple and complex validation",
      "main": "index.js",
      "homepage": "https://github.com",
      "url": "https://github.com/",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/"
      },
      "scripts": {
        "start": "webpack-dev-server --mode development --env  --open --hot --port",
        "build": "./node_modules/.bin/webpack --mode production"
      },
      "author": "Harish",
      "contributors": [
        "Harish"
      ],
      "peerDependencies": {
        "react": "^16.6.1",
        "react-dom": "^16.6.3",
        "prop-types": "^15.5.4"
      },
      "devDependencies": {
        "@babel/core": "^7.8.4",
        "@babel/plugin-proposal-class-properties": "^7.10.4",
        "@babel/preset-env": "^7.8.4",
        "@babel/preset-react": "^7.8.3",
        "babel-core": "^6.26.3",
        "babel-loader": "^8.0.6",
        "webpack": "^4.41.6",
        "webpack-cli": "^3.3.11"
      }
}

.babelrc file: .babelrc 文件:

{
    "presets": ["@babel/preset-env","@babel/preset-react"],
    "plugins": [
        "@babel/plugin-proposal-class-properties"
    ]
}

Thanks in advance.提前致谢。

You need to add that to your .babelrc file, not package.json您需要将其添加到您的.babelrc文件中,而不是package.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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