1

ok when i run :

npm install nodemon -g

it returns :

/home/ubuntu/.node/bin/nodemon -> /home/ubuntu/.node/lib/node_modules/nodemon/bin/nodemon.js
[email protected] /home/ubuntu/.node/lib/node_modules/nodemon
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

or

npm install forever -g

or any node install i then can't access the command afterwards:

nodemon: command not found

but i can run them if i reference the file directly as is the case of forever:

/home/ubuntu/.node/lib/node_modules/forever/bin/forever  server/app.js &

works just fine.... why? fixes?

profile...

  GNU nano 2.2.6                            File: /home/ubuntu/.profile                                                               

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
    export PATH = /home/ubuntu/.node/bin:$PATH

fi

Commands! :

echo $PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

And

ls -la
drwxrwxr-x 2 ubuntu ubuntu 4096 Dec  6 14:42 .
drwxrwxr-x 4 ubuntu ubuntu 4096 Dec  6 12:24 ..
lrwxrwxrwx 1 ubuntu ubuntu   39 Dec  6 14:42 forever -> ../lib/node_modules/forever/bin/forever
lrwxrwxrwx 1 ubuntu ubuntu   42 Dec  6 14:19 nodemon -> ../lib/node_modules/nodemon/bin/nodemon.js

Weird give me this on rersart now:

-bash: export: `=': not a valid identifier
-bash: export: `/home/ubuntu/.node/bin:/home/ubuntu/.node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games': not a valid identifier
2
  • 2
    Apparently, the path where npm is installing the binaries to isn’t in your PATH then. Commented Dec 6, 2014 at 14:31
  • yeah and I've been reading that I need to edit the bashrc or something but a little unsure how to go about it.. Commented Dec 6, 2014 at 14:34

2 Answers 2

1

your node install is whacked

Below are the steps to install Node.js from source (OSX/linux)

NOTE - this installs Node.js which gives you both node as well as npm, they come together per release.

to start fresh remove prior node and npm installs as well as these :

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

download source from : https://nodejs.org/en/download/stable/
or if you need a particular release https://nodejs.org/download/release

Once you have expanded then cd into the source code dir

cd node-v5.5.0  # or whatever current name is

You may/should issue all following cmds as yourself NOT root (sudo)

Pick one of these NODE_PARENT locations to define where node gets installed into :

export NODE_PARENT=/some/desired/install/path_goes_here
export NODE_PARENT=/usr/local/bin/nodejs   # use this ONLY if you MUST install as root (sudo)
export NODE_PARENT=${HOME}/nodejs-v0.10.33 # Recommended - its owned by you NOT root

export PATH=${NODE_PARENT}/bin:${PATH}      # so executables are found
export NODE_PATH=${NODE_PARENT}/lib/node_modules # so node can find its modules dir

./configure   --prefix=${NODE_PARENT}

make
make install

which puts it into dir defined by above --prefix

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

IMPORTANT - put above three export xxx=yyy commands into your ~/.bashrc or some such to persist these environment variable changes

Sign up to request clarification or add additional context in comments.

Comments

0

Add /home/ubuntu/.node/bin to your PATH.

e.g. in your .profile or .bashrc file, add:

export PATH = /home/ubuntu/.node/bin:$PATH

* EDIT *

I would not put the udpated path inside that if statement, as they're independent facts (whether or not you have a home bin and whether or not you're setting your node module path).

Also, make sure you reloaded your .profile after editing it:

source /home/ubuntu/.profile

3 Comments

this doesn't work... updating answer with my bassrs and profile
can you echo $PATH on that machine to verify that it's being set there? Also, ls -la /home/ubuntu/.node/bin. Could also be a permission issue; I assume you're logged in as the user 'ubuntu'?
Good. Looks like your profile changes aren't reflected in the state of your system. See my updated answer for possible fixes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.