Mathee
Mathee

Reputation: 711

Cordova Installation issue :not installed properly and cordova command is working only on c:\>

I followed https://cordova.apache.org/docs/en/latest/guide/cli/ and https://www.youtube.com/watch?v=Vngqn6pS74A to install cordova. I have node 4.4.5 version.

When I gave the command C:>npm install -g cordova below are created in C drive seperately (not inside a one folder)

C:\

I also get bellow errors,

npm WARN engine [email protected]: wanted: {"node":"0.8.x || 0.10.x"}       
 (current: {"node":"4.4.5","npm":"2.15.5"})
 npm WARN deprecated [email protected]: This package has been discontinued 
 in favor of lodash@^4.0.0.

when I type C:>cordova, it respnds the command. cordova version installed is 6.2.0

But if I call cordova in other directory eg: C:\CordovaProjects>cordova

then cordova command "is not recognized as an internal or external command"

What I am I doing wrong?

Thanks Mathee

p.s

C:\Users\MatheeshaF>npm config list
; cli configs
user-agent = "npm/2.15.5 node/v4.4.5 win32 x64"

; userconfig C:\Users\MatheeshaF\.npmrc
prefix = "C:\\"

; builtin config undefined

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\MatheeshaF
; HOME = C:\Users\MatheeshaF
; 'npm config ls -l' to show all defaults.

with help of comments I managed to create a project. still cannot add platform. Get below errors,

 C:\CordovaProjects\TestApp>cordova platform add android
    Error: Failed to fetch platform android
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: connect EACCES 103.245.222.162:443

Upvotes: 0

Views: 1468

Answers (3)

Gandhi
Gandhi

Reputation: 11935

First thing is to ensure that you install cordova globally using the -g option as follows:

npm install -g cordova

Also ensure that nodejs installtion path is set in system environment's Path variable.

Infact if you follow the Official Cordova CLI guide properly, you wont face such issues as even the nodejs path setting will also happen automatically.

Your platform add android command is failing due to connection issue. Ensure that your firewall network or anti virus is not blocking the dependency downloads while adding android platform.

Upvotes: 1

dariru
dariru

Reputation: 501

Your npm prefix is not set properly.

  1. Run npm bin -g and npm config get prefix
  2. If there is a result other than C:\\, add this to your path

It should look similar to this

%USERPROFILE%\AppData\Roaming\npm

You can refer here how to do it in windows 10 https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10

For Windows 10,

Settings > System > About > System Info > Environmental Variables 

Edit path and append %USERPROFILE%\AppData\Roaming\npm at the end

  1. set your npm prefix by npm config set prefix %USERPROFILE%\AppData\Roaming\npm

Upvotes: 2

rahlrokks
rahlrokks

Reputation: 501

You need to run this command at

C:\Users\your-user-name>npm install -g cordova

Upvotes: 1

Related Questions