When trying to run cordova cli on OSX get an error
env: node\r: No such file or directory
I got the latest version of cordova from npm so I think it is 3.0.7
When trying to run cordova cli on OSX get an error
env: node\r: No such file or directory
I got the latest version of cordova from npm so I think it is 3.0.7
The problem seems to be that cordova is in dos format
once I converted it to Unix format it seems to work. I don't get the env: node\r: No such file or directory error.
I used dos2unix to make the change https://code.google.com/p/rudix/downloads/detail?name=dos2unix-5.3.3-0.pkg
On my machine the cordova file was actually in usr/local/lib/node_modules/cordova/bin/cordova
Solution:
$ brew install dos2unix
$ find /usr/local/lib/node_modules -name "*.js" | xargs sudo dos2unix
Details:
The problem for OP was to do with Git, However I am taking a moment to mention the quick fix for most of it's cases
The problem will show up if Node tries to execute .js
file which has windows style line endings. Problem might come from third party npm packages which has .js
files of that kind.
As @Leo mentioned Dos2Unix is the answer, Here is the chain of commands for an example situation while I was trying to install Slack-cli
> npm install -g slack-cli
> slackcli
env: node\r: No such file or directory
The fix looks like
> brew install dos2unix
> find /usr/local/lib/node_modules/slack-cli -name "*.js" | xargs sudo dos2unix
> slackcli --help
Walla..
The problem seems to be that cordova is in dos format
once I converted it to Unix format it seems to work. I don't get the env: node\r: No such file or directory error.
I used dos2unix to make the change https://code.google.com/p/rudix/downloads/detail?name=dos2unix-5.3.3-0.pkg
On my machine the cordova file was actually in usr/local/lib/node_modules/cordova/bin/cordova
On my Mac OS X.
I just ran into the same problem : My files had their line endings changed to CRLF(windows) instead of LS(unix).
It made Cordova and Node unable to compile the project with the error :
env: node\r: No such file or directory
The culprit was GIT which was on AUTOCRLF I don't know why. I ran the following command in the terminal :
git config --global core.autocrlf input
Then I had to delete the project and reclone it from GIT and it worked like a charm.
For me problem is in installed gulp library in file:
'/node_modules/gulp/bin/gulp.js'
It has '\r' in the end of '#!/usr/bin/env node' line. Version:
"github:gulpjs/gulp#4.0"
It was fixed by setting:
git config --global core.autocrlf input
And reloading repository
In my case the solution was to run cordova with sudo (ubuntu 20.04)
© 2022 - 2024 — McMap. All rights reserved.