Open coocier opened 5 years ago
在components/目录下有一个ProductList的组件,
import React from 'react'; import PropTypes from 'prop-types'; import { Button } from 'antd';
const ProductList = (props) => { return Hello world {props.name}
};
export default ProductList;
ProductList.propTypes = { name: PropTypes.string };
在roadhog server下能正常运行没有报错,但是运行build命令时,提示报错 ![2018-10-08_154122.png](https://i.loli.net/2018/10/08/5bbb0a434f700.png) 用浏览器打开dist文件中的index.html文件,在console面板得到如下信息 ![2018-10-08_154022.png](https://i.loli.net/2018/10/08/5bbb09fe5406c.png) 查询starkoverflow后发现好像跟 'prop-types' 有关, 移除 ` import PropTypes from 'prop-types'; ` 移除 ` ProductList.propTypes = { name: PropTypes.string }; ` 后编译顺利通过,无报错 附上package.json 代码
{ "private": true, "scripts": { "start": "roadhog server", "build": "roadhog build", "lint": "eslint --ext .js src test", "precommit": "npm run lint" }, "dependencies": { "antd": "^3.10.0", "babel-plugin-import": "^1.9.1", "dva": "^2.4.0", "prop-types": "^15.6.2", "react": "^16.2.0", "react-dom": "^16.2.0" }, "devDependencies": { "babel-plugin-dva-hmr": "^0.4.1", "eslint": "^4.14.0", "eslint-config-umi": "^0.1.1", "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.6.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.1.0", "husky": "^0.12.0", "redbox-react": "^1.4.3", "roadhog": "^2.4.5" } }
#### What do you expected?(预期的正常效果) build顺利进行,没有报错信息 #### What happen?(发生了何种非正常现象) 提示 Failed to compile. & Duplicate declaration "React" #### Re-producible online demo (可复现的在线demo)
+1 Have same issue. While React is only defined one in the file still compile fails on my bitbucket pipelines Node 11 container.
BTW, in my case the build works fine in local.
Environment(required) | 环境(必填)
What did you do? Please provide steps to re-produce your problem.(请提供复现步骤)
在components/目录下有一个ProductList的组件,
const ProductList = (props) => { return
};
export default ProductList;
ProductList.propTypes = { name: PropTypes.string };
{ "private": true, "scripts": { "start": "roadhog server", "build": "roadhog build", "lint": "eslint --ext .js src test", "precommit": "npm run lint" }, "dependencies": { "antd": "^3.10.0", "babel-plugin-import": "^1.9.1", "dva": "^2.4.0", "prop-types": "^15.6.2", "react": "^16.2.0", "react-dom": "^16.2.0" }, "devDependencies": { "babel-plugin-dva-hmr": "^0.4.1", "eslint": "^4.14.0", "eslint-config-umi": "^0.1.1", "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.6.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.1.0", "husky": "^0.12.0", "redbox-react": "^1.4.3", "roadhog": "^2.4.5" } }