I have a ton of code I'd like migrate from gatsby-image to gatsby-plugin-image through gatsby-codemods. I have followed their docs here. So the problem is I use yarn for my project and get an `env: node\r: No such file or directory. I tried solving this in vi with: (as I think this is because yarn uses UNIX line endings on all systems)
cd /myPathTo/gatsby-codemods
vi index.js
:set ff=unix
:x
Here is the error I get when I try to run yarn gatsby-codemods gatsby-plugin-image
Error: Command failed with exit code 127: /Users/mypath/node_modules/jscodeshift/bin/jscodeshift.js --ignore-pattern=**/node_modules/** --ignore-pattern=**/.cache/** --ignore-pattern=**/public/** --extensions=jsx,js,ts,tsx --transform /Users/mypath/gatsby-codemods/transforms/gatsby-plugin-image.js ./
at makeError (/Users/mypath/node_modules/execa/lib/error.js:60:11)
at Function.module.exports.sync (/Users/mypath/node_modules/execa/index.js:194:17)
at runTransform (/Users/mypath/node_modules/gatsby-codemods/bin/cli.js:35:33)
at Object.run (/Users/mypath/node_modules/gatsby-codemods/bin/cli.js:63:3)
at Object.<anonymous> (/Users/mypath/node_modules/gatsby-codemods/bin/gatsby-codemods.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
exitCode: 127,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
failed: true,
timedOut: false,
isCanceled: false,
killed: false
How can I resolve this?
CodePudding user response:
Try installing the jscodeshift
dependency via yarn:
npm install -g jscodeshift
I think your issue comes because yarn doesn't convert Windows line endings.
Another workaround is to call the jscodeshift
bin in node_modules
directly, which bypass the shebang at the top of the script:
node node_modules/.bin/jscodeshift -t