I can’t create project using Express Node.js

Asked

Viewed 2,885 times

3

I’m following a tutorial from Node.js and I’m learning about frameworks, but when I try to install the express by cmd error, I’m trying to do it this way:

express aplicativo1

And the error that appears in the cmd is this:

'express' is not recognized as an internal command or external, a operable program or a batch file.

  • Yeah, that way: npm install express

  • How is your package.json?

  • You already did require of express?

  • It worked, in the latest version the installation has to be done this way: npm install express-generator -g

1 answer

10


It seems to me that you are calling 'express' two different packages:

  1. express (https://www.npmjs.com/package/express) and
  2. 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

  • Thank you very much for your reply.

  • Not at all! We are here to help each other. I hope you continue developing in Node.js

  • Oops, may I go on yes, I’m "in love" with language

Browser other questions tagged

You are not signed in. Login or sign up in order to post.