1

I am running Ubuntu 14.04 64 bit. I was able to install Node.js using the following commands:

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

It worked. I tried to install Express with the following command:

sudo npm install -g express --save

This gave the following output:

/usr/lib
`-- express@4.13.4 

However, when I tried to test it, it did not work. I used the following commands:

mkdir test
cd test
express

This threw an error that Express was not installed.

How can I get the npm install to work?

2
  • 1
    The node-express package is already in the default repositories. I was simply wondering why the npm install didn't work, and if the default package was up to date. – Rahul Mukherji Feb 18 '16 at 4:52
  • try to install it with sudo npm install -g express --save – Ramesh Chand Feb 18 '16 at 5:06
1

Alternative package managers generally are good at delivering up-to-date packages across multiple OS platforms, but they are generally not as good as the default system package manager at avoiding conflicts with other packages. I have the node-express package from the Ubuntu Software Center installed in Ubuntu 14.04, and it seems to be working properly when running this single file hello_world code with the command: nodejs hello_world.js # then load http://localhost:3000/ in a web browser to see the output..

const express = require('express')
const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))

The version of node-express from the default repositories in Ubuntu 14.04 is 2.5.8. The version of node-express from the default repositories in Ubuntu 16.04 to Ubuntu 18.04 is 4.1.1. The current version of expressjs from the official Express website is 4.13.4 4.16.1. Express from the default repositories of the latest version of Ubuntu is almost as up-to-date as its latest version.

0

You are most likely missing express-generator, see here for details.

To solve your issue, try

sudo npm install -g express-generator

This will install the express cli tool that you are trying to use (and is not installed).

Edit: Sorry about the necro, didn't see this was an old question. I'll leave the answer here anyway, maybe it'll help someone with this issue in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.