express: command not found after installing express-generator#4.15.5 - node.js

My first post here, after reading hours and solving many problems for me:)
Im running macbook OS X El Captain.
I installed Node v8.9.4
I run "sudo npm install -g express-generator" I get the following feedback:
myname-MacBook-Air:todo myname$ sudo npm install -g express-generator
/Users/myname/.npm-global/bin/express -> /Users/myname/.npm-global/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator#4.15.5
updated 1 package in 1.052s
When I now try to run "express newproject", I get the following error:
myname-MacBook-Air:todo myname$ express newproject
-bash: express: command not found
I have a feeling I might have some paths set up the wrong way. I appreciate help!

The executable is installed in
/usr/local/share/npm/bin/
Try add that directory to your path and it will solve the problem.
export PATH=/usr/local/share/npm/bin:$PATH

Install Express Globally
1] npm install express -g
and also install express-generator locally, If it is not working then try to do that by globally
2] npm install express-generator or npm install express-generator -g

Related

Angular - ng: command not found

I'm trying to learn Angular and my knowledge in terminal is beginner. After I installed Angular and then type ng new my-project. I get the response ng: command not found. I've seen other posts that had this problem and I've uninstalled and reinstalled npm and ng.
The last step I took was npm install -g #angular/cli#latest then ng new my-project.
Then I get ng: command not found.
Guess You are running on Windows
(To make #jowey's answer more straightforward).
Install Angular normally from your bash $ npm install -g #angular/cli#latest
Next is to rearrange the PATHS to
NPM
Nodejs
Angular CLI
in System Environment Variables, the picture below shows the arrangement.
I had that same problem and just solved it.
make sure you have node installed.
after running
npm i -g #angular/cli
when installation is finished, try re-opening your git bash or whatever you're using or open it in a new folder. boom. it worked for me
The error may occur if the NodeJs is installed incorrectly or not installed at all.
The proper way to fix that is to install/reinstall it the right way (check their official website for that), but if you're searching for a quick solution, you can try to install Angular CLI globally:
npm install -g #angular/cli
If it doesn't work and you are in a hurry, use sudo:
sudo npm install -g #angular/cli
Don't forget to reopen your terminal window.
For MacOS
Sometimes the ng command does not get established as a link in /usr/local/bin. I fixed the problem by adding it manually:
ln -s /usr/local/Cellar/node/10.10.0/lib/node_modules/angular-cli/bin/ng /usr/local/bin/ng
It may has not helped OP, but it solved my problem. This answer is to help others who have not tried the command mentioned in OP's question.
Just use npm install -g #angular/cli#latest. It did the trick for me.
If you have already installed #angular/cli
Then you only need to link it to npm using npm link #angular/cli
Otherwise first install angular by npm install #angular/cli and then link.
if you install npm correctly in this way:
npm install -g #angular/cli#latest
and still have that problem, it maybe because you run the command in shell and not in cmd (you need to run command in cmd), check this out and maybe it helps...
If you are working on Windows then do the following:
From this directory:
C:\Users\ [your username] \AppData\Roaming , delete NPM folder then install Angular using this command npm install -g #angular/cli
*Windows only*
The clue is to arrange the entries in the path variable right.
As the NPM wiki tells us:
Because the installer puts C:\Program Files (x86)\nodejs before C:\Users<username>\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm#.
So your path variable will look something like:
C:\<path-to-node-installation>;%appdata%\npm;
Now you have to possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with it the installed Agnular CLI version.
If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this:
…;C:\Users\<username>\AppData\Roaming\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or
…;%appdata%\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.
This worked for me since a while now.
Before wasting lots of time in installing and uninstalling, read this.
If you already installed angular before and found this issue, may be it is the reason that you installed angular before with running terminal as Administrator and now trying this command without administrator mode or vice versa. There is a difference in these two.
If you installed angular without administrator mode you can only use angular commands such as ng without administrator mode. Similarly,
If you installed angular with administrator mode you can use angular commands such as ng in administrator mode only.
100% working solution
1) rm -rf /usr/local/lib/node_modules
2)brew uninstall node
3)echo prefix=~/.npm-packages >> ~/.npmrc
4)brew install node
5) npm install -g #angular/cli
Finally and most importantly
6) export PATH="$HOME/.npm-packages/bin:$PATH"
Also if any editor still shown err than write
7) point over there .
100% working
Windows 10 Only
If you are using Git Bash and also you are sure that you have done all steps that are listed above, still getting an error like this, run following command:
alias ng="C:/Users/<your-username>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng"
then run ng -v
Finally, it works if you see the version of Angular-CLI
I had the same issue in Windows. I could solve it by running the ng command with npm
ng g c test
Error : C:\Users\user\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
Solution :
$ npm run ng g c test
Other solution worked for me to use Windows PowerShell or command prompt instead of bash shell
Most of the time developers install just Node.js and start working on development. This issue related angular cli dependency on your development environment.
You can fix this with command
npm install -g #angular/cli
First of all check by running
npm config get prefix
It should return some thing like (C:\Users\acer\AppData\Roaming\npm)
if it does not return it.
run npm config delete prefix
then run npm install -g #angular/cli#latest
And check by running ng --version
It has solved my problem. Hope it will help you.
**
if you have npm, install run the command
npm install -g #angular/cli
then bind your ng using this:
cd
alias ng=".npm-global/bin/ng"
Follow the Pictures for more help.
Removing NODE and using NVM instead fixed a lot of issues.
removing Node from your system
install NVM from here https://github.com/creationix/nvm
Install Node via NVM: nvm install
stable run npm install -g angular-cli
LINK
Step 1 : Delete "npm" folder from the following path
C:\Users\YourUserName\AppData\Roaming
Step 2 : Once you have the "npm" folder deleted, uninstall Node.Js.
Step 3 : Reinstall Node.JS
Step 4 : Install Angular CLI Using this command npm install -g #angular/cli#latest
Step 5: Now try : ng --version or ng -v
I had a lot of issues installing it on a mac with all the permission errors
Finally the following line solve the issue.
sudo npm i -g #angular/cli
>> npm uninstall -g angular-cli
>> npm uninstall -g #angular/cli
>> npm cache clean
Restart you machine
then >> npm install -g #angular/cli#latest
set Path : C:\Users\admin\AppData\Roaming\npm\node_modules#angular\cli
Hope you never get 'ng' not found
I tried this and everything worked by changing the npm directory.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g jshint
ng --version
You can install npx to use Angular CLI installed in your directory:
npm install -g npx
npx ng serve
You must know the full path of your angular installation.
For example: C:\Users\\AppData\Roaming\npm\node_modules#angular\cli\bin\ng .
Type in cmd, powershell or bash
alias ng="C:\Users\<your username>\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng"
In my case
OS Version: Ubuntu 18.04.4 LTS
Node version v12.16.0
Remove ng from /usr/local/bin by using below command.
sudo rm -r ng
After that, installed ng by using command mentioned below.
sudo npm install -g #angular/cli
For Linux user
$ alias ng="/home/jones/node_modules/#angular/cli/bin/ng"
then check angular/cli version
ng --version
enter image description here
alias ng="C:/Users/<user_name>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng".. This did work..
Happy Coding :)
I guess everyone figured this out years ago but me. simple ng stopped working when I updated node. I tried all the previous suggestions in this thread to no avail but this is my solution. the command npm ng works but darn it I want just ng to work. So
I created a bat filed named ng.bat with this content
npm ng %*
either put ng.bat in a directory recognized by path or add a new path in This Computer / Properties / Advanced System Settings / Environment Variables/ System Variables / Path . For instance I added C:\Shortcuts to path.
EDIT the above answer is not THE REAL SOLUTION. What npm need is to find the npm-cli.js which is located in the npm bin directory. If a path is not set to bin then not work. I just copied npm-cli.js and put it in the npm directoy which has a path set to it.
Windows oriented:
If you're chasing an "update node/angular and I wiped my AppData
folder and now the world hates me stream of errors", then this may help.
Clear out Environment Variable settings for Node/npm/#angular/cli (They don't help)
Install Node.JS/npm from https://nodejs.org/en/ (Remember where you install it)
Confirm the location npm is [currently] running from:
npm config get prefix
Realize that is not where you just install new/fresh Node.
Update npm global pointer (which is not an environment variable)
npm config set prefix "C:\Program Files\nodejs"
Reinstall Angular
npm install -g #angular/cli#latest
Check angular install
ng --version
Hopefully this helps someone. Sorry, you'll have to reinstall any other interesting packages.
I'll add this as "yet another option" which worked for me when none of the other options worked( on windows ).
You can run the angular binary via its full path name.
node C:\Users\user\node_modules#angular\cli\bin\ng.js --version
Oddly enough, adding these paths to my env didn't work...for some reason windows opened editor to edit ng.js file instead of running it.
For me the issue was something with node. Version was very wrong somehow.
Uninstalled node from "Add or remove programs" and then re-installed it using the file from their website.

-bash: express: command not found

After numerous attempts at installing Express, my only output has been as stated in the title. Your help would be much appreciated. Below is a list of commands I've tried.
With my working directory being the directory I want the app to be in,
Trying 'sudo npm install express', I get:
sudo npm install express
Followed by 'sudo npm install -g express-generator, I get:
sudo npm install -g express-generator
Now, running 'express', I get:
"-bash: express: command not found"
I have read through the top answers of 4 to 5 posts to no avail. Please help me!
Your question is not readable. I try to answer: you are on osx, I advice you to install nvm. You can make a google search. Then you can install node.js by: nvm install node and finally you can type nvm use node. This solves your sudo problem and you can install express-generator and other packages without a sudo.

Express module install

I am trying to install express module install, but the issue is that after installation I am still unable to use express.
What I've done:
Install express using cmd - npm install -g express
For some reason it's not installing globally.
Help?
You might want to use the following:
npm install -g express-generator
Source: Issues with installing Express.JS in Windows 7
In later versions of express comand line was migrated to a separate module: express-generetor
use
npm install -g express-generator#3
and could use the express command

install express with npm

I recently installed nodejs version 0.10.26 on ubuntu 64 bit. node -v and npm -v commands run fine and I can see the correct versions. When I do a $ sudo npm install -g express
the installation goes fine. But when I try to create a project with express as $ express myProject I get an error saying
The program 'express' is currently not installed. You can install it
by typing: sudo apt-get install node-express
Do I have to include some path in $PATH in order to run express? Please help.
With Express 4, the application generator was removed and is now available as 'express-generator.' So you need to npm install -g express-generator instead.
Enter the command in your terminal
npm install --save express

Can't get Gulp to run: cannot find module 'gulp-util'

On Windows 7, I've installed gulp as explained here: http://markgoodyear.com/2014/01/getting-started-with-gulp/:
npm install gulp -g
In my app folder: npm install gulp --save-dev
I create a gulpfile.js file.
But then, when I try to run gulp, I get this error message:
module.js:340
throw err;
^
Error: cannot file module 'gulp-util'
at Function.Module._resolveFilename (module.js:338:15)
etc.
But gulp-util is present (in the local app folder) in:
node_modules
gulp
node_modules
gulp-util
Any idea what may be the cause?
UPDATE
From later versions, there is no need to manually install gulp-util.
Check the new getting started page.
If you still hit this problem try reinstalling your project's local packages:
rm -rf node_modules/
npm install
OUTDATED ANSWER
You also need to install gulp-util:
npm install gulp-util --save-dev
From gulp docs- getting started (3.5):
Install gulp and gulp-util in your project devDependencies
If you have a package.json, you can install all the current project dependencies using:
npm install
Any answer didn't help in my case.
What eventually helped was removing bower and gulp (I use both of them in my project):
npm remove -g bower
npm remove -g gulp
After that I installed them again:
npm install -g bower
npm install -g gulp
Now it works just fine.
Linux Ubuntu 18:04 user here.
I tried all the solutions on this board to date. Even though I read above in the accepted answer that "From later versions, there is no need to manually install gulp-util.", it was the thing that worked for me. (...maybe bc I'm on Ubuntu? I don't know. )
To recap, I kept getting the "cannot find module 'gulp-util'" error when just checking to see if gulp was installed by running:
gulp --version
...again, the 'gulp-util' error kept appearing...
So, I followed the npm install [package name] advice listed above, but ended up getting several other packages that needed to be installed as well. And one had a issue of already existing, and i wasn't sure how to replace it. ...I will put all the packages/install commands that I had to use here, just as reference in case someone else experiences this problem:
sudo npm install -g gulp-util
(then I got an error for 'pretty-hrtime' so I added that, and then the others as Error: Cannot find module ___ kept popping up after each gulp --version check. ...so I just kept installing each one.)
sudo npm install -g pretty-hrtime
sudo npm install -g chalk
sudo npm install -g semver --force
(without --force, on my system I got an error: "EEXIST: file already exists, symlink". --force is not recommended, but idk any other way. )
sudo npm install -g archy
sudo npm install -g liftoff
sudo npm install -g tildify
sudo npm install -g interpret
sudo npm install -g v8flags
sudo npm install -g minimist
And now gulp --version is finally showing:
CLI version 3.9.1
Local version 3.9.1
Try to install the missing module.
npm install 'module-name'
Same issue here and whatever I tried after searching around, did not work. Until I saw a remark somewhere about global or local installs. Looking in:
C:\Users\YourName\AppData\Roaming\npm\gulp
I indeed found an outdated version. So I reinstalled gulp with:
npm install gulp --global
That magically solved my problem.
You should install these as devDependencies:
- gulp-util
- gulp-load-plugins
Then, you can use them either this way:
var plugins = require('gulp-load-plugins')();
Use gulp-util as : plugins.util()
or this:
var util = require('gulp-util')
This will solve all gulp problem
sudo npm install gulp && sudo npm install --save del && sudo gulp build
None of the other answers listed here-- at least by themselves-- solved this for me.
I'm using Ubuntu 20.04 on Windows Linux Subsystem (WSL2). After reinstalling gulp globally with npm install gulp -g seemingly I needed to log out of my WSL instance and log back in again (closing and reopening my CLI was enough).
Hopefully this helps someone else.
I'm using Linux Mint 20.3. Had this error. Nothing helped.
gulp --version
node:internal/modules/cjs/loader:988
throw err;
^
Error: Cannot find module 'gulp-cli'
Found a solution after 2 hours of trying different things.
"sudo" ! simple as that.
sudo gulp --version
CLI version: 2.3.0
Local version: 3.9.1
Some gulp commands should be used with sudo to avoid errors
In most cases, deleting all the node packages and then installing them again, solve the problem.
But In my case, the node_modules folder has no write permission.
I had the same issue, although the module that it was downloading was different.
The only resolution to the problem is run the below command again:
npm install

Resources