Nodejs on Windows, npm doesn't install modules from registry - node.js

I'm having a problem with my new installation of Node.js (windows 64 bit).
I'm trying to install the express module inside a project of mine but I can't work it out.
I type this command :
npm install -g express
However this is the result of the command
├── escape-html#1.0.1 ├── merge-descriptors#0.0.2 ├── cookie-signature#1.0.5 ├── utils-merge#1.0.0 ├── cookie#0.1.2 ├── range-parser#1.0.2 ├── finalhandler#0.3.2 ├── fresh#0.2.4 ├── media-typer#0.3.0 ├── methods#1.1.0 ├── vary#1.0.0 ├── parseurl#1.3.0 ├── serve-static#1.7.1 ├── content-disposition#0.5.0 ├── path-to-regexp#0.1.3 ├── depd#1.0.0 ├── qs#2.3.3 ├── on-finished#2.1.1 (ee-first#1.1.0) ├── debug#2.1.0 (ms#0.6.2) ├── etag#1.5.1 (crc#3.2.1) ├── send#0.10.1 (destroy#1.0.3, ms#0.6.2, mime#1.2.11) ├── proxy-addr#1.0.4 (forwarded#0.1.0, ipaddr.js#0.1.5) ├── accepts#1.1.4 (negotiator#0.4.9, mime-types#2.0.4) └── type-is#1.5.4 (mime-types#2.0.4)
It's the list of dependecies needed by express but there's no download of them.
The first time I tried to use npm I had this problem (https://github.com/npm/npm/issues/4808)
There were many solutions to solve it, one of them consist in disable the layer ssl for the connection to the npm online registry but I don't think there's a connection between this solution (that I applied) and the problem.
Thank you in advance,
Luca

The express module should be installed on a per project basis.
npm install --save express

Related

express on alpine linux - creating express application fails

I'm trying to create a node js application on alpine linux.
I just did an
apk add nodejs
And now I just tried this command:
myserver:/var/www/widgets# npm install express -g
express#4.14.0 /usr/lib/node_modules/express
├── escape-html#1.0.3
├── utils-merge#1.0.0
├── cookie-signature#1.0.6
├── merge-descriptors#1.0.1
├── methods#1.1.2
├── fresh#0.3.0
├── path-to-regexp#0.1.7
├── vary#1.1.0
├── encodeurl#1.0.1
├── range-parser#1.2.0
├── parseurl#1.3.1
├── array-flatten#1.1.1
├── etag#1.7.0
├── content-type#1.0.2
├── cookie#0.3.1
├── content-disposition#0.5.1
├── serve-static#1.11.1
├── depd#1.1.0
├── qs#6.2.0
├── on-finished#2.3.0 (ee-first#1.1.1)
├── finalhandler#0.5.0 (unpipe#1.0.0, statuses#1.3.0)
├── debug#2.2.0 (ms#0.7.1)
├── proxy-addr#1.1.2 (forwarded#0.1.0, ipaddr.js#1.1.1)
├── accepts#1.3.3 (negotiator#0.6.1, mime-types#2.1.12)
├── type-is#1.6.13 (media-typer#0.3.0, mime-types#2.1.12)
└── send#0.14.1 (destroy#1.0.4, ms#0.7.1, statuses#1.3.0, mime#1.3.4, http-errors#1.5.0)
But when i try to then create an express application, I'm getting an error.
myserver:/var/www/widgets# express testapp
-ash: express: not found
myserver:/var/www/widgets#
I'm not sure what I need to do next.
Thanks.
The issue seems to be that you want to install the express-generator module:
$ npm install express-generator -g
Once you've done this, you can then use:
$ express myapp
To generate your new application, where myapp is the name of the application.
Source: Express application generator

NPM to deploy software

I'd like to use NPM to deploy my NodeJS + ExpressJS websites (API rest + front).
What i'm doing for now :
I setup a private NPM repository
I push my software as a NPM package to this repository
I do npm install mysoftware
Now, the problem, I have to do : node node_modules/mysoftware/bin.js
After step 4. I have the following file tree :
.
└── node_modules
├── my-software
│   ├── bin.js
│   ├── package.json
│   └── src
├── some-required-module
│   ├── HISTORY.md
│   ├── index.js
│   ├── LICENSE
│   ├── package.json
│   └── README.md
I don't like this file tree because everything is a the same level : my software and its dependancies, it makes it very messy.
I'd like it to be this way :
my-software
├── bin.js
├── package.json
├── src
└── node_modules
├── some-required-module
│   ├── HISTORY.md
│   ├── index.js
│   ├── LICENSE
│   ├── package.json
│   └── README.md
Is there a way to install an npm package as a project, and therefore have the file tree I'd like ?

NPM Installs Not Working as Intended

Sometimes then I run npm commands in the ubuntu console, e.g.
npm install forever -g
I get such feedback from the console and it is unclear to me is it installed? Is this a list of dependencies? Is this an issue? How should I proceed fixing this?
forever#0.14.1 /usr/local/lib/node_modules/forever
├── colors#0.6.2
├── timespan#2.3.0
├── optimist#0.6.1 (wordwrap#0.0.3, minimist#0.0.10)
├── nssocket#0.5.3 (eventemitter2#0.4.14, lazy#1.0.11)
├── cliff#0.1.10 (eyes#0.1.8, colors#1.0.3)
├── winston#0.8.3 (cycle#1.0.3, stack-trace#0.0.9, eyes#0.1.8, isstream#0.1.2, async#0.2.10, pkginfo#0.3.0)
├── nconf#0.6.9 (ini#1.3.4, async#0.2.9, optimist#0.6.0)
├── utile#0.2.1 (deep-equal#1.0.0, ncp#0.4.2, async#0.2.10, i#0.3.3, mkdirp#0.5.1, rimraf#2.4.0)
├── flatiron#0.4.3 (optimist#0.6.0, director#1.2.7, prompt#0.2.14, broadway#0.3.6)
└── forever-monitor#1.5.2 (watch#0.13.0, minimatch#1.0.0, ps-tree#0.0.3, broadway#0.3.6)
This is not an error message, everything installed just fine.
Output such as this shows you the other packages that were installed as dependencies for the package you have installed.

node.js ( how to create express)

lee-ui-MacBook-Pro:test1 ErinLee$ sudo npm install -g express
Password:
express#4.9.5 /usr/local/lib/node_modules/express
├── merge-descriptors#0.0.2
├── utils-merge#1.0.0
├── fresh#0.2.4
├── cookie#0.1.2
├── escape-html#1.0.1
├── range-parser#1.0.2
├── cookie-signature#1.0.5
├── finalhandler#0.2.0
├── vary#1.0.0
├── media-typer#0.3.0
├── parseurl#1.3.0
├── methods#1.1.0
├── serve-static#1.6.3
├── path-to-regexp#0.1.3
├── depd#0.4.5
├── qs#2.2.4
├── on-finished#2.1.0 (ee-first#1.0.5)
├── etag#1.4.0 (crc#3.0.0)
├── proxy-addr#1.0.3 (forwarded#0.1.0, ipaddr.js#0.1.3)
├── accepts#1.1.1 (negotiator#0.4.8, mime-types#2.0.2)
├── send#0.9.3 (destroy#1.0.3, ms#0.6.2, mime#1.2.11)
├── type-is#1.5.2 (mime-types#2.0.2)
└── debug#2.0.0 (ms#0.6.2)
lee-ui-MacBook-Pro:test1 ErinLee$ express
-bash: express: command not found
lee-ui-MacBook-Pro:test1 ErinLee$ express test1
-bash: express: command not found
lee-ui-MacBook-Pro:test1 ErinLee$
what's wrong?? why i can't create express??
i'm in terminal on mac os X
express is a node.js module.
You are looking for the express generator:
npm install -g express-generator
https://github.com/expressjs/generator

Express JS command is not working

After installing Express with Node.js using this command:
npm install -g express
I am not able to use the express command, I get thrown the error in windows that express is not an internal or external command.
I've checked to make sure Express was installed by using the command npm -g ls and express shows up in there like this:
C:\wamp\www\blackbook>npm -g ls
C:\Users\Chris\AppData\Roaming\npm
└─┬ express#4.0.0
├─┬ accepts#1.0.0
│ ├── mime#1.2.11
│ └── negotiator#0.3.0
├── buffer-crc32#0.2.1
├── cookie#0.1.0
├── cookie-signature#1.0.3
├── debug#0.8.0
├── escape-html#1.0.1
├── fresh#0.2.2
├── merge-descriptors#0.0.2
├── methods#0.1.0
├── parseurl#1.0.1
├── path-to-regexp#0.1.2
├── qs#0.6.6
├── range-parser#1.0.0
├─┬ send#0.2.0
│ └── mime#1.2.11
├─┬ serve-static#1.0.1
│ └─┬ send#0.1.4
│ ├── fresh#0.2.0
│ ├── mime#1.2.11
│ └── range-parser#0.0.4
├─┬ type-is#1.0.0
│ └── mime#1.2.11
└── utils-merge#1.0.0
Any ideas as to what I'm doing wrong or what I can do to fix it so I can use express?
I see you installed the latest Express.js version 4.0.0. In this version they removed the application generation from express itself. This is now a separated module called express-generator.
To install it, use the following command
$ npm install -g express-generator
To read more, check out the Express.js docs #executable

Resources