cordova is installed but not starting up - node.js

I installed node.js 8.9.3 and a successfully installed with following message
This package has installed:
• Node.js v8.9.3 to /usr/local/bin/node
• npm v5.5.1 to /usr/local/bin/npm
Make sure that /usr/local/bin is in your $PATH.
I run following command in terminal mac ...
$ $PATH
And i get following return..
-bash: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
Q1. What does that last line mean? No such file or directory?
.. after that i run following commands..
$ which node
And following is response
/usr/local/bin/node
and similar for
$ which npm
And following is response
/usr/local/bin/npm
I think everything is fine till now..
Now i installed ...cordova typing..
$ sudo npm install -g cordova
It is installed and the next lines after completing installation i see ..
/Volumes/macHDD/Users/samz/.npm-packages/bin/cordova -> /Volumes/macHDD/Users/samz/.npm-packages/lib/node_modules/cordova/bin/cordova
+ cordova#8.0.0
updated 1 package in 27.977s
Q2. is it successfully installed? if so.. why is this not as global?
when i test typing
$ which cordova
terminal says nothing.. I also tested typing
$ cordova -version or $ cordova --version .. or even if i type
$ cordova create hello com.example.hello HelloWorld
I am "slapped" by terminal :(
-bash: cordova: command not found
...
in the last night. i was successful in installing cordova, and I created 2 test apps.. i was able edit them, even I run those apps on android emulator and on my ios device+emulator.
during building/preparing one of my app, I tried to create one more app project through a seperate terminal instance. And there I saw .. like no cordova.
I terminated first instance where cordova was working.. and reopened terminal to test if this is an issue.. and yes.. it was .. I could never work on cordova again.
Can somebody tell me what is the issue. ?.
it's very irritating now.
Thank you

I don't know how this is resolved..
I reinstalled node, npm, java, cordova (several times), but nothing could resolve.
and today .. i upgraded node9.3.0 from node8.9.3.. but still the same errors.
Now i had..
Muhammads-MacBook-Pro:colors muhammadfarooqi$ node --version
v9.3.0
Muhammads-MacBook-Pro:colors muhammadfarooqi$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
Muhammads-MacBook-Pro:colors muhammadfarooqi$ npm -version
5.5.1
Muhammads-MacBook-Pro:colors muhammadfarooqi$ cordova -version
8.0.0
i was about to kill myself.. but i found something on the internet with some other issue.. and i run the same command.
sudo rm -rf node_modules
sudo npm install
and then i installed cordova.
and wow... cordova is there :)
i dont' know what exactly was the solution .. I dont' know what this line of code did.. I know the above line removed node_modules and 2nd lines installed npm.. and now I am seeing cordova is running.
Please somebody, if my solution works for anybody, kindly comment. thank you

Your first issue is because you typed just $PATH. This is then expanded to its value, and then the shell attempts to execute it, which is obviously not possible.
To check your current PATH, type echo $PATH instead.
Your second issue is probably due to a partial configuration to use a user-specific global package directory.
By default, packages are installed in /usr/local/lib/node_modules, with symlinks for binaries in /usr/local/bin, which requires root access (sudo). You have at one point configured npm to install in a different directory (~/.npm-packages), but did not include the bin sub-directory in your PATH.
So you need to either finalise the configuration (see https://docs.npmjs.com/getting-started/fixing-npm-permissions for details), or revert to using /usr/local.

Related

Node and npm not found after restarting macOS

I am using my corporate's laptop and am a new mac User (used Ubuntu before) :
OS: macOS Monterey Version 12.2
There are two accounts, administrator and mine - I don't have sudo rights. To install homebrew without administrator rights, I followed this Installation.
To install the node - I used brew install node. Both node -v and npm -v were working. When I restarted the laptop, I cannot find node/npm.
On running $ node -v, I get -bash: node: command not found (I changed my default terminal from zsh to bash and the output is the same for both of them)
I tried this solution but couldn't find nvm in the system. Am new to mac and I believe nvm is some kind of package manager like homebrew so this solution is not applicable to me (correct me if I am wrong).
How can I install things in my system without sudo rights and keep them permanently(like node)?
EDIT:
(After adding brew to the PATH) On running - brew list|grep node, I got - node
$ echo $PATH gives /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/parthkapadia/homebrew/bin
EDIT2:
Adding brew to path solved the issue, now I can even access node and npm (even after restarting). I used this site to add homebrew/bin to path (in zsh terminal)
The issue was homebrew's path. It was not added to the PATH variable.
When I restarted the system, homebrew was no longer in the PATH (as it was temporarily added probably when I installed it). As homebrew was not added to PATH, the terminal didn't recognize brew or any package installed using it like node or npm.
I solved it by adding Users/username/homebrew/bin to PATH. The steps I followed are -
cd - to move to the home directory
touch .zshrc to create .zshrc file as it didn't exist
nano .zshrc to open the file for editing
Added export PATH=$PATH:/Users/yourusername/homebrew/bin in the file (this appends homebrew/bin to the PATH variable)
Now the terminal can recognize brew and hence node and npm too.
Refer this for more detailed explanation on how to add to PATH in macOS.
Thanks to all the people who helped in the comments.

Npm not working (openSSL configuration error windows10x64)

I was getting this error whenever I try the npm command in powershell:
**~ $ node -v
v17.1.0
~ $ npm -v
OpenSSL configuration error:
74240000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
74240000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
74240000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:
OpenSSL configuration error:
A8250000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
A8250000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
A8250000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:**
Another thing I noticed is that the node must have updated incorrectly because even though it gives me a version, I cannot uninstall it and cannot find the install files in my program files. I am at a total loss and about to just reset my computer to default. I want to repair it but everything online tells me to use npm, which in itself is not possible.
I have tried using the "set OpenSSL" command to empty or to a dummy file but it does not seem to do anything.
Go to the Windows control panel and click on Uninstall a program, select Node.js and click on the uninstall tab to uninstall the node and npm successfully. Restart your system.
Then go to https://nodejs.org/en/ to download 16.13.0 LTS version and install it
Please check environment path using PowerShell
check environment path:
cmd /c echo %PATH%' or 'cmd /c echo %OPENSSL_CONF%
You will get C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf path so reset the environment path for openssl using below comment on PowerShell
set OPENSSL_CONF=''
after that, the problem will be fixed.
this issue already issued on Nodejs GitHub.
https://github.com/nodejs/node/issues/40547
the only thing that you're to do is to create a new archive called openssl.cnf
in this route:
C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf
Save the work and run in cmd: npm --version
Had this issue in a conda environment. Fixed by installing node with next command: conda install -c conda-forge nodejs=16.3.2
Try to uninstall the node from your project directory.
npm uninstall node
Most probably you have 2 different versions of Node installed on your system.
If my solution does not work for you. Try the other suggestions with uninstalling Node from the system.
My solution was to use another node version in this case 15.8.0, you can try with others most recently versions. When I did this npm was installed correctly:

npm commands not working on Bash on Ubuntu on Windows (WSL)

I am running latest stable windows with bash on Ubuntu running through cmder wslbridge (i tried running directly through bash but same errors). Moving to my windows based react-native folder and trying to run some cli like npm run android , react-native run-android , gradlew clean is always producing errors;
while surprisingly some other commands like npm start work properly...
which npm print out; /usr/local/bin/npm
i have npm installed on windows and inisde Ubuntu and whereis npm produce this
I am really confused here; when running npm commands inside the bash onto windows folders which npm should be triggered? the windows or WSL one?!
I've tried a lot of suggested solution, but nothing seems to be working...
As you have said you are unsure what is actaully running when you run the commands. if you run the following commands it might make it clear as to what is actually running.
➜ ~ whereis npm
npm: /usr/local/bin/npm /home/damo/.nvm/versions/node/v8.11.1/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd
➜ ~ which npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm
➜ ~ npm --version
6.4.1
➜ ~ sudo find / -name npm
/home/damo/.npm/10.52.63.39_4783/npm
/home/damo/.npm/npm
/home/damo/.nvm/versions/node/v10.4.1/bin/npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm
/home/damo/.oh-my-zsh/plugins/npm
/mnt/c/Program Files/nodejs/node_modules/npm
/mnt/c/Program Files/nodejs/node_modules/npm/bin/npm
/mnt/c/Program Files/nodejs/npm
/mnt/c/Users/stangerd/AppData/Roaming/npm
➜ ~ echo $PATH
/home/damo/.nvm/versions/node/v8.11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu/Scripts:/mnt/c/Program Files/cmder/vendor/conemu-maximus5:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/HashiCorp/Vagrant/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Beyond Compare 4:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ stangerd/AppData/Roaming/npm
➜ ~ nvm use 10
Now using node v10.4.1 (npm v6.1.0)
➜ ~ echo $PATH
/home/damo/.nvm/versions/node/v10.4.1/bin:/usr/local/sbin:/usr/local/bin:........
You can see that for me i also have many versions of npm, but that its my WSLs current nvm version that is being used (shown by running which npm). This is because when the path is searched the first one found will be used. the first instance of npm in all the folders in my path is in /home/damo/.nvm/versions/node/v8.11.1/bin. Notice that when using nvm the path will be changed when switching node versions and that conveniently it puts this new path on the front of all the existing path folders.
Its also worth checking the alias set as this gets evaluated before the path is even queried. Just run alias to get a list.
Hope that this helps to find what is actually running. I'm interested to hear how you get on.

Ionic, npm and cordova commands all require sudo to work

The sudo, by the looks of what I have seen in some forums, is why I am getting an error when running sudo ionic emulate ios in this post New to ionic - can’t build for ios (9) on El Capitan, and sudo ionic is required, deprecated npmconf. (I am running El Capitan btw).
Whenever I need to use an ionic, npm, or cordova command, I always have to put sudo in front of it otherwise I get a "bash command not found" error. I have tried to use this fix https://www.npmjs.com/package/npm-sudo-fix but it doesn't work. This is what happens in the log:
Dylans-MBP:Ionic Projects Dylan $ sudo npm install -g npm-sudo-fix
Password:
/usr/local/bin/npm-sudo-fix -> /usr/local/lib/node_modules/npm-sudo-fix/index.js
npm-sudo-fix#0.1.3 /usr/local/lib/node_modules/npm-sudo-fix
└── spawny#0.0.1 (cmdify#0.0.4)
Dylans-MBP:Ionic Projects Dylan$ sudo npm-sudo-fix
chown: /users/root/.npm: No such file or directory
Edit (28 August 2018):
I wrote this post and answer many years ago when I was not very familiar with the terminal. Now that I am more experienced, I can recommend the better solution. It is good practice to avoid unnecessary usages of sudo.
I believe the problem is caused by installing node JS from the installer from the node JS website. This version of node JS seems to write various files in the filesystem as root, potentially (and unnecessarily) causing global packages to require root permissions to be installed.
The ideal solution would be to completely remove node JS, that was installed from the node JS installer from the website, from your machine (see https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/). Then install node from a commandline package manager, such as homebrew.
Original Answer (2016)
Finally came up with a solution by playing with the permissions! Hopefully I didn't stuff up anything. (I am a terminal noob btw.) Anyway, here's the solution.
Run this code here in the terminal (you may or may not have to run cd .. before hand)
sudo chown -R $USER /usr/local/
This changes the permissions of every thing inside the local folder (hence the -R which means recursive). (I found this line somewhere in the ionic forums).
Now, you have to reinstall cordova and ionic
sudo npm install -g cordova
sudo npm install -g ionic
For me anyway, after I do this, I can type ionic and not get any errors. I get this in the terminal if I run cordova though.
/usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/Dylan/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
What I did to fix this was do this (after opening up a new terminal window):
sudo chown -R $USER Dylan
(Dylan is my user folder; replace it with yours. Also, you may have to do a cd .. before running that line And that fixes the permissions for that config file. Now running cordova works without errors! Woot! That error might come back though, so you have to run that line of code again.
Hope this helps somebody!

Node cli on Msysgit on WIndows 10

I recently decided to pick up Node on my personal laptop, which I upgraded to Windows 10, and the Node cli seems to hang when I try to run it.
Simply typing node on the console will not initiate the interface, and to do anything else I need to Ctrl+C out of it.
Additionally, running some npm commands take longer than they used to on my laptop. More noticeably, npm init seems to hang after confirming the information to be written to package.json.
Node version is 4.0.0
npm version is 2.14.2
Are there any known issues with Node and npm on Windows 10?
Edit:
After some troubleshooting, I've figured out the error only happens on Msysgit. Neither of the issues happen on the standard command prompt of Windows.
I had the same issue on Windows 7 with Node version 6.11.0 and Msysgit's MINGW64 terminal window.
The problem was caused by the an alias provided by Msysgit as demonstrated below:
$ alias node
alias node='winpty node.exe'
The solution is to run the command:
$ unalias node
Then node will run correctly.
You can add the unalias node command into your .bashrc file in your HOME directory to make this permanent.
Good luck!
Jeff

Resources