https://stackoverflow.com/questions/13553404/express-is-not-recognized-command-windows




Okay I am running node on windows (7). Using npm I just installed modules to d:\ directory. Therefore my files structure looks like the following:

D:\
  -myproject
     -node_modules
        -.bin
        -express

However, when I am in this 'myproject' directory, I can't seem to run 'express' for example:

D:\myproject\express site
'express' is not recognized as an internal or external command, operable program or batch file.

Am I doing anything wrong?

My guess is that you didn't install Express globally. You can install express globally (and therefore available in your PATH) with the following command (see http://expressjs.com/guide.html) :

npm install -g express

The way you install it is available only in the folder that you installed it and there is nothing wrong with that approach. There is very little advantage of having it available globally.

If express is not in your PATH you can run it by entering the full path to it:

\myproject\node_modules\.bin\express.cmd

    Try:

    npm install -g express-generator@3

    That solved problem for me.

    Edit: for version 4

    npm install express-generator -g

      Here's what to type in the command line to make it work in windows:

      npm install express-generator -g

      [Source: http://expressjs.com/starter/generator.html]

      With the release of Express 4.0.0 it looks like you need to do

       npm install -g express-generator.

        We need to set path for express global directory

        C:\Users[User_Name]\AppData\Roaming\npm\

        After add a new path, please reopen the CMD console

          Tried all of these and never worked. A repair of Node.js by kicking of installation and selecting repair option does the magic.

          Cheers

            I was able to fix this with:

            npm install express-generator -g

            Express is loaded someplace else and not in the windows path environment variable. You need to find were express.exe is installed and add the path. Maybe something like ;"C:\Program Files\Express\bin";

              I have the same problem and understand the solution, but i can´t undestand why, running npm install -g express, express.bat isn´t added automatically to Path.

              Running with npm install -g express have the same result. Download packages and store in node_modules, but express.bat isn´t added to path.

                Run the node command prompt as administrator and then install express globaly
                npm install -g express
                and then go to folder where you want to install express generator, open command prompt there and run this command
                npm install express-generator, it will then fix the issue

                I have tried out all above solutions, but its did't worked for me, finally I have re-installed the node.jswith newer version and started to express install process again. Its worked for me.

                npm install -g express
                npm install -g express-generator

                What command are you using to open the directory?

                That error means CMD can't find the "express" executable in the current directory.

                Use the "PUSHD" command or "CD /D" instead of "CD"

                @Echo OFF
                PUSHD "D:\myproject\express" || (Echo bad folder)
                express.exe "site"
                Pause&Exit

                Running "npm install express" and "npm install express-generator" from your project directory will resolve the issue (if that helps).

                But, this doesn't solve the problem of being global.

                What worked for me was:

                I used the windows command prompt instead of the node.js command prompt.

                In windows 10 simply type in the windows search bar for "node"

                You see a node.js desktop app and a node js command prompt.

                Choose the "node js command prompt"

                Type in the command prompt

                npm install express-generator -g

                Then navigate somewhere and type in:

                express your-website-text-here -e

                A directory with express files will be generated. Also now you won't see the express error.