Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version: 0.12.0. /usr/bin/env: ‘node\r’: No such file or directory #424

Closed
gavinxgu opened this issue Apr 23, 2021 · 15 comments · Fixed by #549
Closed

Version: 0.12.0. /usr/bin/env: ‘node\r’: No such file or directory #424

gavinxgu opened this issue Apr 23, 2021 · 15 comments · Fixed by #549
Labels

Comments

@gavinxgu
Copy link

Execute jscodeshift with an error

/usr/bin/env: ‘node\r’: No such file or directory 
@machty
Copy link

machty commented May 5, 2021

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

@ZhangYiJiang
Copy link

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

@roddds
Copy link

roddds commented Jul 9, 2021

This is still an issue in 0.13.0.

@michaldudak
Copy link

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.

@fijiwebdesign
Copy link

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"
  },

@dijs
Copy link

dijs commented Oct 20, 2021

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.

@ElonVolo ElonVolo added the bug label May 6, 2022
@Krisztiaan
Copy link

You could also use npx jscodeshift instead.

@sibelius
Copy link
Contributor

any workaround on m1?

@jediswear
Copy link

jediswear commented Nov 3, 2022

any workaround on m1?

@sibelius, works on m1

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

@sibelius
Copy link
Contributor

node node_modules/.bin/jscodeshift -t ...

is not working for me

@pvinis
Copy link

pvinis commented Feb 2, 2023

it gives the same error even with npx jscodeshift.

@Daniel15
Copy link
Member

Daniel15 commented Feb 28, 2023

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.

@dreyks
Copy link

dreyks commented Mar 2, 2023

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

@sibelius
Copy link
Contributor

sibelius commented Mar 8, 2023

@sibelius
Copy link
Contributor

sibelius commented Mar 8, 2023

anybody can give a try here #549?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.