jscodeshift PropTypes改为proptypes,跳过节点模块中的所有文件。

问题描述 投票:0回答:1

我对后台react设置完全陌生。一切都很顺利,直到我开始造型......我得到了这个

TypeError: Cannot read property 'object' of undefined
./node_modules/radium/lib/components/style.js
node_modules/radium/lib/components/style.js:23
  20 | displayName: 'Style',
  21 | 
  22 | propTypes: {
> 23 |   radiumConfig: _react.PropTypes.object,
     | ^  24 |   rules: _react.PropTypes.object,
  25 |   scopeSelector: _react.PropTypes.string
  26 | },

在谷歌上,我找到了jscodeshift... 所以我跑了一下。

% jscodeshift --extensions js -t react-codemod/transforms/React-PropTypes-to-prop-types.js  node_modules/radium/lib/components/ --explicit-require=false
Processing 3 files...
Spawning 3 workers...
Sending 1 files to free worker...
Sending 1 files to free worker...
Sending 1 files to free worker...
All done.
Results:
0 errors
0 unmodified
3 skipped
0 ok
Time elapsed: 0.770seconds

我又上网查了一下,其他人都有导入的问题,比如 material-UI,代码中没有返回,或者其他的 js 文件。我甚至删除了node模块,并重新安装了npm,但没有用。我似乎找不到任何解决我的问题的方法。

下面是我的package.JSON依赖关系......

"dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "@types/react-burger-menu": "^2.6.1",
    "jscodeshift": "^0.9.0",
    "prop-types": "^15.7.2",
    "radium": "^0.26.0",
    "react": "^15.6.2",
    "react-burger-menu": "^1.12.0",
    "react-dom": "^15.6.2",
    "react-scripts": "3.4.1",
    "yarn": "^1.22.4"
  },

任何帮助是非常感激的.ps:我是开放的,完全重新设置了整个项目。

node.js npm package.json react-proptypes jscodeshift
1个回答
0
投票

重新安装所有的东西后,这个问题得到了解决。

我想我出错的地方可能是:1.安装或重新安装了版本不兼容的包,即不同版本的react-dom和react,等等。

给未来google用户的建议。慢慢来,尤其是在转换到TS的时候。确保基本的react应用在运行。然后在迁移到TS的过程中,一步一步地转换,或者添加其他你需要的模块。

一切顺利!

© www.soinside.com 2019 - 2024. All rights reserved.