-bash express: command not found - javascript

I am getting a very odd error trying to install the express-generator with and without sudo.
I need to run: npm install express-generator -g and then express --ejs name_here but when executing the first command, I get the following error:
npm ERR! Darwin 15.2.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "express-generator" "-g"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /Users/[name]/.npm/lib/node_modules/express-generator/LICENSE
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/[name]/Documents/Projects/MEAN Stack Tutorial/npm-debug.log
After trying sudo npm install express-generator -g I get this:
/Users/[name]/.npm/bin/express -> /Users/[name]/.npm/lib/node_modules/express-generator/bin/express
express-generator#4.13.1 /Users/[name]/.npm/lib/node_modules/express-generator
├── sorted-object#1.0.0
├── commander#2.7.1 (graceful-readlink#1.0.1)
└── mkdirp#0.5.1 (minimist#0.0.8)
Then running express --ejs name_here returns -bash: express: command not found
Is there a way I can solve this issue? The other questions on SO seem to have fixed the issue by trying sudo but not for me.

Try to use an express command with a full path: /Users/[name]/.npm/bin/express or sudo /Users/[name]/.npm/bin/express.
Looks like PATH variable wasn't set after installation. (https://en.wikipedia.org/wiki/PATH_(variable))

Related

Error message installing npm

I get the following message when I type npm install from the root directory
$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! path /package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open
npm ERR! package.json ENOENT: no such file or directory, open '/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! path npm-debug.log.3965331654
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.3965331654'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, open 'npm-debug.log.3965331654']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.3965331654' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.
Probably you are trying to run this code in empty directory. This is not right. npm install command installs all packages and dependencies which are listed in package.json file.
If you want to start npm project and make npm install run successfully, first run npm init command. This will create you package.json and there you will be able to enter all the packages and deps. Then you will be able to run npm install
Here is a tutorial
And one more

Node.JS impossible to install ionic

I've recently installed Node.JS for ionic framework. But when i type on the terminal :
npm install -g cordova ionic
I've got this error :
npm ERR! Darwin 14.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! path /usr/local/lib/node_modules/cordova
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/cordova'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/cordova']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/usr/local/lib/node_modules/cordova' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/cordova'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/cordova']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back syscall: 'rmdir',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/cordova' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/TARRADOUJL/npm-debug.log
During the installation of Node.JS I need to make sure that /usr/local/bin is in your $PATH.
And when i type
$PATH
The results is :
-bash: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin: No such file or directory
I'm not a "Pro" with the line commands.. but i think i need to change my $PATH for install ionic right ? In this case ? How can i do please?
Try sudo npm install -g cordova. You may have to input your password.

I try to install express-generator, but I receive a curious error message

I've searched every SO question even closely related and everything I've tried hasn't worked. Any ideas? I can post the debug log, but it is quite long and I can't get it to format correctly. Let me know if this would be helpful.
~/desktop/node_tutorial $ npm install express-generator -g
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "express-generator" "-g"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /usr/local/lib/node_modules/express-generator
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, rmdir '/usr/local/lib/node_modules/express-generator'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, rmdir '/usr/local/lib/node_modules/express-generator']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/express-generator' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, rmdir '/usr/local/lib/node_modules/express-generator'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, rmdir '/usr/local/lib/node_modules/express-generator']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/express-generator' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/*****/Desktop/node_tutorial/npm-debug.log
Looks like it wants you to be an administrator:
...
Please try running this command again as root/Administrator
...
Try sudo npm install -g express-generator

not able to install coffeescript

seems like a nifty thing to use, but it's not installing.
Last login: Sun Mar 9 14:14:32 on ttys001
users-Mac-Pro:~ mac$ sudo npm install -g coffee-script
Password:
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/mkdirp
npm http 200 https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
/usr/local/bin/coffee -> /usr/local/lib/node_modules/coffee-script/bin/coffee
/usr/local/bin/cake -> /usr/local/lib/node_modules/coffee-script/bin/cake
coffee-script#1.7.1 /usr/local/lib/node_modules/coffee-script
└── mkdirp#0.3.5
users-Mac-Pro:~ mac$ npm install -g coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/coffee-script'
npm ERR! error rolling back coffee-script#1.7.1 { [Error: EACCES, unlink '/usr/local/lib/node_modules/coffee-script']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/coffee-script' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/coffee-script'
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/coffee-script']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/coffee-script' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! cwd /Users/mac
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/lib/node_modules/coffee-script
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/coffee-script'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/mac/npm-debug.log
npm ERR! not ok code 0
what's wrong? I tried installing it with and without global installs

NPM no longer working

so I wasn't paying attention and ran this command-
npm install npm install jasmine-node -g
which caused this -
npm http GET https://registry.npmjs.org/install
npm http GET https://registry.npmjs.org/jasmine-node
npm http GET https://registry.npmjs.org/npm
npm http 200 https://registry.npmjs.org/install
npm http GET https://registry.npmjs.org/install/-/install-0.1.7.tgz
npm http 200 https://registry.npmjs.org/install/-/install-0.1.7.tgz
npm http 200 https://registry.npmjs.org/jasmine-node
npm http GET https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz
npm http 200 https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz
npm http 200 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/-/npm-1.2.15.tgz
npm http 200 https://registry.npmjs.org/npm/-/npm-1.2.15.tgz
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/install'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/install']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/install',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/install',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:297:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g"
npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn
npm ERR! node -v v0.8.17
npm ERR! npm -v 1.2.0
npm ERR! path /usr/local/lib/node_modules/install
npm ERR! fstream_path /usr/local/lib/node_modules/install
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/install'
npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/jasmine-node',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/jasmine-node',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:297:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g"
npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn
npm ERR! node -v v0.8.17
npm ERR! npm -v 1.2.0
npm ERR! path /usr/local/lib/node_modules/jasmine-node
npm ERR! fstream_path /usr/local/lib/node_modules/jasmine-node
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node'
npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back npm#1.2.15 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/npm' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/npm' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g"
npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn
npm ERR! node -v v0.8.17
npm ERR! npm -v 1.2.0
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn/npm-debug.log
npm ERR! not ok code 0
Now when I try and run
npm install jasmine-node -g
I get
-bash: /usr/local/bin/npm: No such file or directory
What's going on?
When you run npm install -g somepackage, you may get an EACCES error asking you to run the command again as root/Administrator. It's a permissions issue.
It's easy to fix, open your terminal (Applications > Utilities > Terminal)
sudo chown -R $USER /usr/local
** I strongly recommend you to not use the package management with sudo (sudo npm -g install something), because you can get some issues later **
Reference: http://foohack.com/2010/08/intro-to-npm/
** Update **
The reason is because this can cause permissions problems with lots of other apps, so I'd suggest not doing this.
A better solution when you are installing globally:
sudo chown -R `whoami` ~/.npm
Tried it myself.
You will need to install npm again. If you use git, this is the easiest way:
git clone http://github.com/isaacs/npm.git
cd npm
sudo make install
Otherwise, there is an install script too:
curl http://npmjs.org/install.sh | sh
(possibly you will need to use sudo sh instead of sh).
Then install your module again:
sudo npm install jasmine-node -g
EDIT 23/01/2014:
Now npm comes with NodeJs itself, so just reinstall NodeJs.
Look at the error
Please try running this command again as root/Administrator.
You need to run this with sudo
$ sudo npm install jasmine-node -g
This worked for me (OSX). I had to run it in my user directory.
cd ~
curl -L http://npmjs.org/install.sh | sudo sh
I was able to get around the permissions issues by setting my packages to install locally with a one-line "$HOME/.npmrc" file:
prefix=${HOME}/.npm_packages

Categories

Resources