I have a problem on npm installation
I have created a project say project A
cd ~/projectA
npm install sails
but sails command is not fo
I can give you an inelegant solution, which is working for me. I just exported my path in my .bashrc file.
export PATH="$PATH:./node_modules/.bin"
Edit: It's been a while, but I have changed my strategy to use npm scripts instead. In the above case, setup package.json as follows:
"scripts": {
"sails": "sails"
}
Which you can then run with
npm run sails
or with arguments
npm run sails -- <args>
In my ~/.bashrc
, I have the following:
function nbin {
local dir;
dir=$(npm bin)
if [ -d "$dir" ]; then
( # subshell to not change this shell's $PATH
PATH=$dir:$PATH
eval "$@"
)
else
echo "\"$dir\" is not an npm binary directory." >&1
return 1
fi
}
I can then run executable foo
in the .bin
directory as:
nbin foo