如何解决迁移错误 env: node\r: from Gatbsy-images to Gatsby-plugin-images with gatsby-codemods?
How to resolve migration error env: node\r: from Gatbsy-images to Gatsby-plugin-images with gatsby-codemods?
我有大量代码想通过 gatsby-codemods 从 gatsby-image 迁移到 gatsby-plugin-image。我已经关注了他们的文档 here。所以问题是我在项目中使用 yarn 并得到一个 `env: node\r: No such file or directory。我尝试在 vi 中解决这个问题:(我认为这是因为 yarn 在所有系统上都使用 UNIX 行尾)
cd /myPathTo/gatsby-codemods
vi index.js
:set ff=unix
:x
这是我尝试 运行 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
我该如何解决这个问题?
尝试通过 yarn 安装 jscodeshift
依赖项:
npm install -g jscodeshift
我认为你的问题是因为 yarn doesn't convert Windows line endings。
另一种解决方法是直接调用 node_modules
中的 jscodeshift
bin,绕过脚本顶部的 shebang:
node node_modules/.bin/jscodeshift -t
我有大量代码想通过 gatsby-codemods 从 gatsby-image 迁移到 gatsby-plugin-image。我已经关注了他们的文档 here。所以问题是我在项目中使用 yarn 并得到一个 `env: node\r: No such file or directory。我尝试在 vi 中解决这个问题:(我认为这是因为 yarn 在所有系统上都使用 UNIX 行尾)
cd /myPathTo/gatsby-codemods
vi index.js
:set ff=unix
:x
这是我尝试 运行 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
我该如何解决这个问题?
尝试通过 yarn 安装 jscodeshift
依赖项:
npm install -g jscodeshift
我认为你的问题是因为 yarn doesn't convert Windows line endings。
另一种解决方法是直接调用 node_modules
中的 jscodeshift
bin,绕过脚本顶部的 shebang:
node node_modules/.bin/jscodeshift -t