I have installed Node.js through the installer on their webpage and added it’s path to my environment variable so I can use node and npm through the command line. If I make an express app, it works, but I have to create it manually.
This is fine I guess, but I was wondering why I can’t use the express command? I am getting
`express` is not recognized as an internal or external command, operable program or batch file.
I noticed that express installs in C:\Username\node_modules instead of where I thought it would go, in C:\Program Files\Nodejs\node_modules. Is this a problem?
Although this is not necessarily a problem, it’s annoying and and error is an error even if you can navigate around it.
Although you can reference other node modules even if they are not in the node directory, as far as I understand node requires the modules to be in the
node_modulesfolder within theNodejsdirectory in order to automatically find them. (I had a similar issue on osx and this method solved it.)Try moving the contents of
C:\Username\node_modulesintoC:\Program Files\Nodejs\node_modules\Alternatively,
You can also install modules globally with:
which allows you to access them without having to worry about your node directory, although these are then more difficult to manage and “you should try to avoid if you can”.
From the Node Blog:
Resources