Error running react-codemod for javascript with flow project

1k views Asked by At

Error encountered running in javascript project using flow.

npx react-codemod rename-unsafe-lifecycles

How do I get this codemod to run properly. This is required to upgrade the project's version of React to 16.9+

 ERR src\datatypes\Mammografie.js Transformation error (Cannot read property 'process' of undefined)
TypeError: Cannot read property 'process' of undefined
    at process (C:\Users\guus-\AppData\Roaming\npm-cache\_npx\37416\node_modules\react-codemod\node_modules\flow-parser/flow_parser.js:308:70)
    at Object.<anonymous> (C:\Users\guus-\AppData\Roaming\npm-cache\_npx\37416\node_modules\react-codemod\node_modules\flow-parser/flow_parser.js:2:2)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Module._compile (C:\Users\guus-\AppData\Roaming\npm-cache\_npx\37416\node_modules\react-codemod\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Object.newLoader [as .js] (C:\Users\guus-\AppData\Roaming\npm-cache\_npx\37416\node_modules\react-codemod\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
All done.
Results:
278 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 26.769seconds
1

There are 1 answers

0
fugaflex On

Worked for me using jscodeshift and --no-babel flag, not npx package. Seems that npx react-codemod doesn't accept any flags by now:

jscodeshift --no-babel --parser=flow -t /path/to/react-codemod/transforms/class.js /path/to/src