Closed gavinxgu closed 1 year ago
Ran into this because I tried to install with yarn via yarn global add jscodeshift
, but yarn doesn't convert windows line endings
You have to install with npm per the readme (npm converts the line endings):
npm install -g jscodeshift
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 ...
This is useful if jscodeshift is being called as part of a script, and the package is installed separately or if it's not possible to use a different package manager
This is still an issue in 0.13.0.
Another workaround is to call the jscodeshift bin in node_modules directly, which bypass the shebang at the top of the script
Note that you can't do that if you use Lerna as it creates a bash script in place of the node_modules/.bin/jscodeshift
JS file.
You can also reference the ./node_modules/.bin/jscodeshift
directly in an npm script. eg:
package.js
"scripts": {
"codeshift": "node ./node_modules/.bin/jscodeshift",
"start": "yarn codeshift -t ./index.js --stdin < ./sample-files.txt",
"docs": "yarn codeshift --help",
"test": "jest"
},
Still an issue in the latest version. Only way to combat this was to downgrade to 0.11.0 which does not have the same issue.
You could also use npx jscodeshift
instead.
any workaround on m1?
any workaround on m1?
@sibelius, works on m1
Another workaround is to call the
jscodeshift
bin innode_modules
directly, which bypass the shebang at the top of the script -node node_modules/.bin/jscodeshift -t ...
This is useful if jscodeshift is being called as part of a script, and the package is installed separately or if it's not possible to use a different package manager
node node_modules/.bin/jscodeshift -t ...
is not working for me
it gives the same error even with npx jscodeshift
.
This is strange... I'm not sure how Windows line endings ended up in the file. I do publish jscodeshift from a Windows PC, but I also publish other things and haven't had an issue with any of the others. Hmm.
I think the issue is not in the windows line-ending per se, I guess node is smart enough to work with it. what's not smart enough is bash - the \r
in the shebang string turns it into #!/usr/bin/env node\r
here more on this https://techtalkbook.com/env-noder-no-such-file-or-directory/
anybody can give a try here https://github.com/facebook/jscodeshift/pull/549?
Execute jscodeshift with an error