I have Ubuntu 13.10 and I installed Node.js using:
sudo apt-get install nodejs
I then installed Express using:
sudo npm install -g express
I had to use sudo for the express installation because I got errors when I tried to do it without.
The problem is when I try to create an express app or even type express -v at the command line nothing happens i.e.:
kwal0203#Kanes-laptop:~$ express -v
kwal0203#Kanes-laptop:~$
I can see the express files have been installed in the usr/local/lib/node_modules/express directory and the is also a file named express in the usr/local/bin/ directory which I assume is some type of shortcut or link or something.
Any ideas on why express is not working?
Thanks any help appreciated!
The solution was simply to install the nodejs-legacy package:
sudo apt-get install nodejs-legacy
Related
I've built a Javascript app running on Node within my MacOS environment, and everything works great. Now I've created an Azure Ubuntu server, rsync'd the source from my machine.
I've duplicated the app requirements by installing npm, node, and all the packages required. I SSH into the server and when I run the app from the Ubuntu server via
$node app.js
All that is returned is
$
Reading that Ubuntu uses nodejs-legacy, i've also tried
$nodejs app.js
Same result
$node -v
v4.7.2
I've also built a package.json file and when executing with
npm start
it immediately returns back to $.
The reason why it wasn't working is the default APT repository that is called when installing nodejs on Ubuntu is outdated. I ran the following to code to fix the problem. It automatically uninstalls all the other incorrect packages, sets the correct repository, and re-installs.
# Sets up the correct APT repository hosted by NodeSource, and adds the PGP key to the system's APT keychain
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
# Installs Node.js
$ sudo apt-get install -y nodejs
# Updates NPM
$ sudo npm install npm --global
All apps work as intended now!
I have installed nodejs,express on ubuntu but when i type "express test" command on terminal on ubuntu, its not creating the folders etc (package.json,app.js, view folder ect).It simply prompts in the next line.
Please help
If you want to generate the scaffolding for a new express app you can use the express-generator.
First you need to install the needed module globaly.
sudo npm install express-generator -g
Then you can use this command to generate your scaffolding.
express <my_app>
More info here http://expressjs.com/starter/generator.html
I am trying to run a simple http server in my project directory. All I need is GET request support, so I can GET html/css/js/etc.
For that I wanted to use http-server from npm.
I installed it with npm install http-server -g
Now I cd to my project folder where it has the index.html file, I open the terminal and run http-server
But when I open my browser at http://localhost:8080/index.html - it can't connect to the host.
Am I missing something?
Okay, the issue was - I had another package installed on Ubuntu, which is also called node
Node JS package is called nodejs on my system and I think that http-server is looking specifically for 'node'.
In order to work around this:
I removed the node package with sudo apt-get remove node and created a symlink for nodejs:
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
First install npm.
Second npm install http-server -g.Next append after the http-server url template url like http-server C:\xampp\htdocs\
I am kind of new to node.js. I installed node fine and it works. I can run the node command in the terminal as well as the node package manager command(npm). Working on a Mac by the way. So I installed express globally with the following command:
sudo npm install -g express
After I was done installing it globally I installed it in a small folder where I am working on a project.
sudo install express
That gave me a node_modules folder inside of my site folder. After I was done that I went to install stylus using the express command and I got the error that express is not a command.
express -c stylus
Can anyone shed some light on this issue? I also tried to link the global express to the folder where I am working on the project using the following command:
sudo npm link express
The terminal said that this command ran, but I still cannot run the express command.
Thanks for asking questions on this one. I found that running express-generator instead of just express fixed the problem. The following code in the terminal worked.
sudo npm install -g express-generator
Thanks again,
If your express binary keeps doing nothing. Install node-legacy:
sudo apt-get install nodejs-legacy
on ubuntu 14.04 nodejs 0.10 express did not work on terminal, though
sudo apt-get install nodejs-legacy
made it to work.
I faced similar issue. I tried all the solutions mentioned here. However couldn't get my problem solved.
This happens when location of express and nodejs is not same.
Issue arises when Node is installed using homebrew.
Just use this command export PATH=/usr/local/share/npm/bin:$PATH
NOTE: replace path with the path of express.
Follow this link for help.
Make sure you have package.json & index.js files. And instaled express-generator with -g tag.
If still getting error use like ex:npx express --view=pug myapp --git
I fixed this on my mac by forcing my user to own /usr/local/lib and running the command to install express-generator globally:
sudo chown -R $USER /usr/local/lib
then:
npm install -g express-generator
After this you can go ahead and run your express commands:
express -h
I'm new with nodejs and trying to learn it. I have installed node framework express as global module by command:
$ sudo npm install express -g
This works correctly and I have it in /usr/lib/node_modules. Then I'm creating a new project on express:
$ express app
But this doesn't create project folder and does not return any error code, clear node code works fine. Anybody knows how to detect and fix this error?
found it. the npm package is actually named express-generator
sudo npm install -g express-generator
you can then use
express mytestapp
that results in :
olivier#****:~/workspace$ express mytestapp
create : mytestapp
create : mytestapp/package.json
create : mytestapp/app.js
create : mytestapp/public
create : mytestapp/public/javascripts
create : mytestapp/public/stylesheets
create : mytestapp/public/stylesheets/style.css
create : mytestapp/routes
create : mytestapp/routes/index.js
create : mytestapp/routes/users.js
create : mytestapp/views
create : mytestapp/views/index.jade
create : mytestapp/views/layout.jade
create : mytestapp/views/error.jade
create : mytestapp/bin
create : mytestapp/bin/www
create : mytestapp/public/images
install dependencies:
$ cd mytestapp && npm install
run the app:
$ DEBUG=my-application ./bin/www
Cheers !
Olivier
Source : http://expressjs.com/guide.html#executable
For me the solution was simply to install the nodejs-legacy package:
sudo apt-get install nodejs-legacy
First thing to try is if the plugin is installed:
$ npm -g ls | grep express
If nothing is returned, try reinstalling it.
Since in this case it was still installed, the next solution was to reinstall Node entirely.
There is a great post on cleaning up Node installations here: Uninstall Node.JS using Linux command line?
This is what I did to get mine to work and make sure everything was working ok on Ubuntu 12.04 running Node 0.8.21 and Express 3.2.0.
First install express
sudo npm install –g express
Now check that express is working by querying it for the version:
express -V
Now I went and created an express app:
cd /usr/lib/node_modules
sudo express -s -e expressTestApp
The following was output:
create : expressTestApp
create : expressTestApp/package.json
create : expressTestApp/app.js
create : expressTestApp/public
create : expressTestApp/public/javascripts
create : expressTestApp/public/images
create : expressTestApp/public/stylesheets
create : expressTestApp/public/stylesheets/style.css
create : expressTestApp/routes
create : expressTestApp/routes/index.js
create : expressTestApp/routes/user.js
create : expressTestApp/views
create : expressTestApp/views/index.ejs
install dependencies:
$ cd expressTestApp && npm install
run the app:
$ node app
So, following the instructions it gave me, I ran the following two commands in sequence:
cd expressTestApp
sudo npm install
After just a minute it finished and I was able to open /urs/lib/node_modules/app.js and work with it. Also, running node app like it said in the instructions during the express module creation worked as well.
From a previous comment, it looks like you might have fixed it by reinstalling node, but I still hope this will help you.
Perhaps a sudo express app might do the trick? (I see you're executing in /var/www, which generally is off limits from regular users?)
As of Ubuntu 16.04 LTS, the problem occurs when express is installed globally. To fix this, make sure you install express to your working directory even if you have installed globally.
Use
sudo npm i express-generator --save
to save it to your working directory in every project you do.
Had this problem and fixed it easily, without having to reinstall nodejs or any other dependency.