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

[Bug]: 'env: node\r: No such file or directory' #21061

Closed
CHE1RON opened this issue Feb 12, 2023 · 7 comments · Fixed by #21180
Closed

[Bug]: 'env: node\r: No such file or directory' #21061

CHE1RON opened this issue Feb 12, 2023 · 7 comments · Fixed by #21180

Comments

@CHE1RON
Copy link

CHE1RON commented Feb 12, 2023

Describe the bug

When migrating CSF 2-3 via npx script, I get this error (which is most commonly related to Windows line endings):

$ npx storybook@next migrate csf-2-to-3 --glob="**/*.stories.tsx"
=> Applying csf-2-to-3: 15 files
env: node\r: No such file or directory

To Reproduce

Run `$ npx storybook@next migrate csf-2-to-3 --glob="**/*.stories.tsx"`

System

Ubuntu 22.04, Node v16 & v18

Additional context

No response

@OlaoluwaM
Copy link

Same here! I'm on MacOS 13.1, Node v16

@OlaoluwaM
Copy link

OlaoluwaM commented Feb 14, 2023

Here is a workaround I found. Instead of npx storybook@next migrate storiesof-to-csf --glob="src/**/*.stories.tsx" run npx --loglevel verbose storybook@next migrate storiesof-to-csf --glob="src/**/*.stories.tsx" this should show you what npx is actually doing. You should see jscodeshift being used. I think that might be the actual problem and not the migration script from storybook. Evidence, this issue: facebook/jscodeshift#424

@OlaoluwaM
Copy link

OlaoluwaM commented Feb 14, 2023

Once you have spotted the line that says npm exec jscodeshift --no-babel -t /path/to/node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js --parser tsx ... (where '...' refers to all your .stories files from the glob you provided) you will need to copy that entire line, replacing npm exec jscodeshift with node node_modules/.bin/jscodeshift as noted by this comment: facebook/jscodeshift#424 (comment)

In the end, it should be node node_modules/.bin/jscodeshift --no-babel -t /path/to/node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js --parser tsx ... instead. Run this and your migrations should work 🙂

@CHE1RON
Copy link
Author

CHE1RON commented Feb 15, 2023

Sounds great, I'll try it out and let you know!

@mandarini
Copy link
Contributor

I am running into the same issue myself!

@shilman shilman moved this to Required for QA in Core Team Projects Feb 20, 2023
@mandarini
Copy link
Contributor

@OlaoluwaM using node node_modules/.bin/jscodeshift --no-babel -t ... makes it work, indeed, for what it's worth! 😅

@shilman
Copy link
Member

shilman commented Feb 21, 2023

Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.53 containing PR #21180 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

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

Successfully merging a pull request may close this issue.

5 participants