Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

env: node\r: No such file or directory with cordova cli

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

like image 258
Leo Avatar asked Aug 28 '13 16:08

Leo


3 Answers

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..

like image 136
nehem Avatar answered Sep 28 '22 17:09

nehem


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

like image 28
Leo Avatar answered Sep 28 '22 16:09

Leo


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.

like image 43
Yahel Avatar answered Sep 28 '22 16:09

Yahel