简体   繁体   中英

React webpack bundling issue

I created a webpack bundle.js for a react component.

When i import it with node_modules folder to another react project it`s working fine.

But when i removed the node_modules folder of that component my new react app is not working.

This is the error :-

Module build failed: ReferenceError: Unknown plugin "transform-object-rest-spread" specified in .....

and following is my package.json

{
  "name": "react-component",
  "version": "0.0.1",
  "description": "Put a description here",
  "main": "build/index.js",
  "dependencies": {
    "react": "^15.5.4",
    "webpack": "^2.6.1",
    "babel-cli": "^6.24.1",
    "babel-core": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-plugin-transform-object-rest-spread": "^6.23.0",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-env": "^1.5.1"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack --watch",
    "build": "webpack"
  },
  "author": {
    "name": "Your name",
    "email": "your email"
  }
}

删除项目的node_modules并运行npm i

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