On the spur of the moment want to learn something, ready to deploy a node. js applet on Heroku. The company computer was not installed with node. js, so download the latest version of node. JS, When I installed express I found that it was not an internal or external command. Then after my tireless efforts, finally found clues, the following share to everyone (I am using the Windows node. js).
Tools/Materials
- node. JS installation Package
Method/Step
First download the node. JS installation package, here I use the official latest v0.10.27
32-bit version:
Http://nodejs.org/dist/v0.10.27/node-v0.10.27-x86.msi
64-bit version:
Http://nodejs.org/dist/v0.10.27/x64/node-v0.10.27-x64.msi
The next step in the installation is not to elaborate.
After installation, you will need to install Express and install it using the familiar NPM Install-g Express command, however, after the installation is successful, you are prompted that express is not an internal or external command.
Why is this so? When we find the installed Express directory, we find a lot less than the previously familiar express.
What do we do? The speculation is that the Express version is updated, but we don't know how to play the new version. So I had to remove the currently installed express and reinstall the previous version to try it. Test OK.
The commands used here are
Uninstall: NPM Uninstall-g Express
Install the specified version: NPM install-g [email protected]
View version: Express-v
Note that the V in Express-v is capitalized, otherwise it will not be recognized in many versions
Of course, you just want to solve the problem that the Express command does not recognize. You've reached your goal at this point. But why don't we use the new version?
Originally, the command tool was separated from the latest express4.0 version (Project address: https://github.com/expressjs/generator), so we also need to install a command tool, the command is as follows:
NPM install-g Express-generator
So I deleted the previous express3.5.0 again install express4.0 and its command tools
Now that we've installed it, we need to test whether the newly installed Express is ready to use
So I used express to create a project:
Express HelloWorld
There have been some changes in the command in the new version, and after creating project, you need to add dependencies and launches with NPM:
CD HelloWorld
NPM Install
NPM start
Then the newly created HelloWorld is already running on Port 3000.
Visit Http://localhost:3000/and see the familiar pages.
and the created catalog effect.
This is really done, and the new version of Express has changed a little. hehe. Other new features await us all to find out.
END
Precautions
- Use the NPM install-g [email protected] command to install the specified version
- Project created with Express must use NPM install to add dependencies in the project directory to run
- Running the app is no longer node App.js but NPM start
Source: http://jingyan.baidu.com/article/922554468a3466851648f419.html
Nodejs small problem: Express is not an internal or external command