Upon trying to install express via npm, bash was simply returning a command not found statement upon running any node module in the shell directly. I went through countless resources and forums to locate the issue and was not succesfull.
This seemed to be the solution for me. I ran the below statement and then proceeded to reinstall express as sudo:
chmod 777 /usr/local/lib
sudo install express -g
Run both commands respectively.
Related
I am having a problem running Sanity's CLI. I have installed the CLI with npm install -g #sanity/cli which works without a problem, and everything is installed correctly (as far as I can tell).
However, trying to use any of their CLI instructions, such as sanity init, I get this error message:
zsh: command not found: sanity
I am using npm version 6.14.11 and node version v14.16.0.
I've also been noticing a few random commands return the same zsh: command not found for various packages.
with npx it works
npx #sanity/cli init
#user1934428 is right.
I just change in the command "sanity ..." to "usr/local/Cellar/node/16.3.0/lib/node_modules/#sanity/cli/bin/sanity ..." and it worked
I had a similar problem on my mac which was caused by not installing sanity globally.
Go to your terminal and enter:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Enter your password then install sanity globally
npm install -g ng
This should solve the issue and sanity commands should work too.
I followed this Up and running with PhoneGap on Mac OSX on every single step but then I got stuck with
I have tried many solutions and fixes but still nothing is working. I followed this answer but still stuck.
What could be the cause for these issues?!
Update1:
When I install cordova using sudo npm install -g cordova I get the following:
Even when I type cordova, I get -bash: cordova: command not found
Update2:
I fixed cordova installation using the following steps:
sudo chown -R $USER /usr/local
sudo chmod -R 0775 /usr/local
Add it to the path using this answer
Add the path to bash_profile using this link
Open the terminal and type cordova -v and you get it working displaying the version
Phonegap is still failing and can't seem to find a fix for it
Why do my macs require me to type sudo before command line installs?
For example, the Yeoman website says to run the command npm install -g yo but it fails unless I type sudo as a prefix sudo npm install -g yo.
The same thing happens while installing compass or nodejs.
It's not like typing sudo is a big deal, but it appears not everyone is required to follow this step.
Is there something I can do to avoid this?
Well the reason is simple: sudo means that you need root(admin) privileges. Thats to avoid that anybody can install softwares on your system. And I am not just talking about people, but more about softwares. It avoids that an other programm can install maleware/virus etc without your permission. It is actually a pretty good thing ;)
I installed django 1.5.1 with PIP.
I am trying to learn Django, and tried to make a test project.
When I run pip freeze, it returns Django==1.5.1 as one of my installed packages.
When I run django-admin.py startproject test_project it returns, -bash: django-admin.py: command not found.
I cannot start this test project. Any advice as to how I can start a new django project?
I am on a Mac OSX 10.5.8.
I found the solution on this page.
I was able to solve my path issue by running:
sudo ln -s /usr/local/lib/python2.7/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
This created a "Permission Denied" error though. I was able to solve that issue by running:
sudo chmod +x /usr/local/bin/django-admin.py
django-admin.py is now working.
I have used follwong command to install (/usr/local/bin)
pip install django
django-admin startproject mysite
just installed new ubuntu vm to test around with node
installed things in this order:
node
mongodb-server
npm
express
mongoose
now, trying to create a new app i noticed express cannot be used in the shell.
express -v returns
express: command not found
i installed npm like this
curl http://npmjs.org/install.sh | sudo sh
and i installed express this way
npm install express
any ideas?
Starting from express 4.00 you also need to install express generator with:
npm install -g express-generator
Only after this will you be able to run express as a command!
For confirmation see: ExpressJS.com - Migrating to Express 4
npm install express -g
You need to install it globally.
Npm 1.0 installs modules locally by default. So the bash executable lives in /node_modules/bin/. You can add that folder to PATH or you can just install express globally so that it's picked up by PATH
I had this problem and was installing node via Homebrew. The problem was being caused by Homebrew.
So I did:
brew uninstall node
and then installed node using the installer on the nodejs.org site.
Then I ran:
npm install -g express
And voila no problems.
With the release of Express 4.0.0 it looks like you need to do sudo npm install -g express-generator.
EDIT 2017-06-29: this answer is 6+ years old, but still gets votes/traffic. Instead (for any new users with problems) I'd trust both NODE_PATH official doc and its corresponding bit about REPL usage before this answer.
Quite similar to this issue, node was not finding my global express install, so a require('express') statement would fail.
What fixed this for me, when a global install wasn't being picked up by node was making sure NODE_PATH env. variable was is set correctly.
On Ubuntu 11.04, with node version 0.5.0-pre, the paths me were:
NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node
So, to clarify you might want to export the above env. variable, or you can just test the above values out by doing:
NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node node ./you_app.js
I had to do a combination of things:
From node.js modules path:
echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bash_profile && . ~/.bash_profile
This sets the file path in bash profile (can be viewed using nano .bash_profile
Slightly modified from Raynos (above) since I needed sudo:
sudo npm install express -g
Slightly modified from Fazi (above) since I needed sudo:
sudo npm install -g express-generator
TEST YOUR APPLICATION:
run `DEBUG=myapp:* npm start`
Ref: http://expressjs.com/en/starter/generator.html
IF you are running windows:
export NODE_PATH="C:\Users\IMarek\AppData\Roaming\npm\node_modules"