It seems to me that you are calling 'express' two different packages:
express
(https://www.npmjs.com/package/express) and
express-generator
(https://www.npmjs.com/package/express-generator)
The first is a web framework and the second is only used to create a directory structure for the web framework express
.
Also note that the -g option of npm serves to install packages globally on your operating system, which in general makes the commands provided by the package stick to the system’s PATH and can be accessed directly from the command terminal.
Thus, the error you got:
'express' is not recognized as an internal or external command, a operable program or a batch file.
It occurred because your operating system did not find the 'express' command in its PATH due to the fact that the package express
does not have an express command, even if it is installed globally. Who has this command is the package express-generator
and in order to be able to use this command from any directory, it is necessary that this package be installed globally, using the -g option of npm.
I hope I have helped to clarify a little more your doubt and continue studying and learning more about Node.js
You installed the express by npm before?
– bfavaretto
Yeah, that way:
npm install express
– DiegoAugusto
How is your
package.json
?– Sergio
You already did
require
ofexpress
?– Sergio
It worked, in the latest version the installation has to be done this way:
npm install express-generator -g
– DiegoAugusto