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

env: node\r: No such file or directory #32

Closed
mekalag opened this issue Jul 3, 2021 · 12 comments
Closed

env: node\r: No such file or directory #32

mekalag opened this issue Jul 3, 2021 · 12 comments

Comments

@mekalag
Copy link

mekalag commented Jul 3, 2021

Hi everyone, I am trying to transform a file called baseSteps.js to webdriverIO file using command

npx jscodeshift ../node_modules/@wdio/codemod/protractor/ test/steps/baseSteps.js

Before this i have installed :
npm install --save-dev @wdio/cli
npx wdio config (ran the configuration wizard) I have configured cucumber framework.

After which I ran
npx jscodeshift ../node_modules/@wdio/codemod/protractor/ test/steps/baseSteps.js

In package.json I have all the dependencies
Screenshot 2021-07-03 at 18 52 06

So when I run npx jscodeshift ../node_modules/@wdio/codemod/protractor/ test/steps/baseSteps.js
it throws :
env: node\r: No such file or directory

Not sure what I am missing. though baseSteps.js file exists in test/steps folder. Can someone suggest?

Note: I am using mac OS. I was going through help in some other articles and I think this issue is caused by line endings with CRLF, where as its must be LF. For ex: mrmlnc/svg2sprite-cli#4
and many more when we search for env: node\r: No such file or directory hopefully this will give an idea

@christian-bromann
Copy link
Member

You were missing a parameter, see our Usage section, I believe it is suppose to be this way:

npx jscodeshift -t ./node_modules/@wdio/codemod/protractor ./test/steps/baseSteps.js

Please let me know if you have further questions.

@mekalag
Copy link
Author

mekalag commented Jul 12, 2021

Unfortunately, using -t parameter dint help. Its still throws env: node\r: No such file or directory.

@erickzhao
Copy link

For reference, I think this is an upstream issue with jscodeshift: facebook/jscodeshift#424

@kliph-gladly
Copy link

It would be helpful to update the docs to indicate that the workaround described here facebook/jscodeshift#424 (comment) works.

@christian-bromann
Copy link
Member

@kliph-gladly mind raising a PR?

@kliph-gladly
Copy link

kliph-gladly commented Feb 23, 2023

I've encountered larger issues with the @wdio/codemod/async adding the await keyword to function calls for functions that do not return promises and failing to add async to anonymous inline functions. I anticipate that I won't be using this in the future.

@christian-bromann
Copy link
Member

You will only need the codemod package as utility to rewrite your tests.

@kliph-gladly
Copy link

Thanks. Yes I'm aware. The larger issue that I mentioned is that the utility produces code with syntax errors.

@christian-bromann
Copy link
Member

Can you provide a code example that causes a syntax error when rewriting the code with this codemod?

@kliph-gladly
Copy link

kliph-gladly commented Feb 23, 2023

Sure:

const foo = function() {
  mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};

produces

const foo = function() {
  await mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};

This is syntactically incorrect for two reasons. The outer function context is not async so it doesn't make sense to use await within it. And the function called in the inner scope does not return a promise, so it doesn't make sense to use await.

@christian-bromann
Copy link
Member

Yep, this is a bug, mind raising a new issue for it?

@kliph-gladly
Copy link

Will do. Thank you.

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

No branches or pull requests

4 participants