`n latest` installing a version other than what it said it would - node.js

I am trying to install the right version of node.js and npm on an Elastic Beanstalk server. Strangely,
sudo n latest
returns this result:
install : node-v7.9.0
mkdir : /usr/local/n/versions/node/7.9.0
fetch : https://nodejs.org/dist/v7.9.0/node-v7.9.0-linux-x64.tar.gz ######################## 100.0%
installed : v0.10.48
Here, installed returns a version different from install. So when I run node -v it returns v7.9.0, but when I run npm run prod (the actually important step), it says npm does not support Node.js v0.10.48 and throws a whole bunch of errors. What gives?

The fix is in. I had to add this command to my .ebextensions config file:
04_node_link:
cwd: /tmp
command: 'sudo ln -sf /usr/local/n/versions/node/7.8.0/bin/node /usr/bin/node'
This should link node.js to yum-installed npm correctly.

Related

`gulp` command doesn't work as expected on Linux

I am trying to set up the needed environment for a project I am gonna work on. I am not able to run gulp command as expected (as it is told on the getting started page of Gulp).
I am using Linux (PopOS) which is based on Ubuntu and Debian.
So, I have tried to fix it in the local project repo - which was unsuccessful.
Then I decided to create a new project directory and see whether it works. I have done these in the new project file:
$ node -v
v8.10.0
$ npm -v
5.6.0
$ npx -v
9.7.1
$ npm install --global gulp-cli
$ npm install --save-dev gulp
After all these, at the last step, when I do:
$ gulp
-bash: /usr/bin/gulp: No such file or directory
this is what I get.
However, if I do this,
$ node_modules/gulp/bin/gulp.js --version
CLI version: 2.2.0
Local version: 4.0.2
I get some result.
Does anybody see why gulp isn't getting in my binary directory? - Even though I have done the same exact steps that are presented on the official website?
This issue was about npm prefix that defines the directory where npm packages will be installed. Because the gulp binary wasn't in one of the directories that is in PATH variable bash wasn't able to find it. Here you can find details about how to fix.

Deleted nvm now npm is not working

I installed nvm to update my node but then decided to uninstall. After updating my node via website, I am not able to get npm installed despite installing a new version of node and using:
sudo curl -L npmjs.org/install.sh | sudo sh
Here is the message I am getting:
-bash: /Users/SICNARF/.nvm/versions/node/v8.2.1/bin/npm: No such file or directory
I think I just have to change the command from non-existing nvm directory to (wherever its supposed to run).
Node.js version management: no subshells, no profile setup, no convoluted API, just simple.
Installation
npm install -g n
Example
$ n 8.2.1
https://www.npmjs.com/package/n

Error: EACCES when creating new Ember project

I just installed Linux Mint (version 17.2) and I'm trying to install Ember. Everything seemed to go fine, but I'm getting this error when I run ember new testProject.
create vendor/.gitkeep
EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
Error: EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
at Error (native)
Per a recommendation in the Ember Documentation I used this guide to install Node.js and NPM. Some of what I've read suggest the issue is nodejs was installed with sudo, but apt-get failed when I didn't use sudo.
I attempted to run the new project anyway. bower install completed successfully. But ember serve failed with Cannot find module 'chalk'.
--Version Info
$ ember --version
version: 1.13.8
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
node: 0.12.7
npm: 2.13.4
os: linux x64
The only command that was needed to run with sudo for me was:
npm install
I suggest you delete node_modules/ in your project directory completely, then run:
sudo npm install
You can also add option --verbose to see if everything is correctly installing and installation isn't stuck.
You could also change permissions for .npm directory to avoid some problems like that in future:
sudo chmod 777 -R /home/mkm/.npm
You can use following commands to install and use npm without sudo:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | NVM_DIR="/home/your-user-name/.nvm" bash
export NVM_DIR="/home/your-user-name/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 0.12
nvm alias default 0.12
npm install -g ember-cli
npm install -g bower
npm install -g phantomjs
Here is a link to nvm repository with latest version and documentation: https://github.com/creationix/nvm

Npm not working after Mavericks update

My npm in terminal isn't working after Mavericks update.
node app.js works well and runs my app, but when I run npm followed by anything I get -bash: npm: command not found. I know this question has been asked before here:
Global installation with npm doesn't work after Mac OS X Mavericks update
and
How do I install a module globally using npm?
and npm not working after reinstalling Mac OS X
, but none of the answers resolved my situation.
$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/mongodb/bin
How did you install node.js ? typically it comes bundled with both node and npm, where both are in the same directory. My suggestion is to remove your current install(s) and do the following with just works.
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
parent_dir=${HOME}/bin_xxxx # replace bin_xxx with something specific
# to node release like bin_v0.10.31
mkdir ${parent_dir}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${parent_dir}/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${parent_dir}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${parent_dir}/nodejs/lib/node_modules
do above AND use syntax : npm install -g some_cool_module
always use the -g for global so it gets installed into dir $NODE_PATH
and not your $PWD
nodejs install gives you npm as well :
ls -la ${parent_dir}/nodejs/bin
For Debian, after installing node do following
curl -k -O -L https://npmjs.org/install.sh
ln -s /usr/bin/nodejs /usr/bin/node
sh install.sh

How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

I installed Node.js with these instructions and it seemed successful:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Then I installed npm with these instructions:
sudo curl https://www.npmjs.org/install.sh | sh
The nodejs installation seemed to work without errors but the npm command gave me a lot of errors. But it seems like they are installed because when I test what version I have they both come up:
nodejs -v
v0.10.30
npm -v
1.4.21
So If this doesn't tell me that I have both programs successfully installed, which I assume I do not, how do I know?
I think your tests tell that both or properly installed.
But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.
Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.
On linux if you wish to install node.js and npm as yourself NOT root :
to start fresh remove prior node.js and npm installs as well as these :
~/.npmrc
~/.npm
~/tmp
~/.npm-init.js
create your ~/bin/ directory if not already created :
mkdir ${HOME}/bin
download source from : http://nodejs.org/download/
cd node-v0.10.30/
./configure --prefix=${HOME}/bin/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${HOME}/bin/nodejs/bin:$PATH
define NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules
do above AND use syntax :
npm install xxxxx -g
always use the -g for global which puts package xxxxx into $NODE_PATH
NOTE - nodejs install gives you npm as well :
ls -la ${HOME}/bin/nodejs/bin

Resources