- For basic installation of Nodejs, please refer to: Setting up a simple webserver using http-server
- Remark, anything inside "<>" should be replaced by your desired folder name or number
- The "myapp1" and "express" can be also renamed, however to clear the confusion, just type as the command says:
EG: replace cd <Where you want your app to be>/express/myapp1 with cd Documents/express/myapp1
- This package is recommended if you want to do Multiplayer
Installing the generator for the Express app
npm install -g express-generator
for Unix-like OS (OSX, Linux, BSD, etc)
sudo npm install -g express-generator
It will ask for password, but won't display anything while user is typing, just type password and enter (This step is very confusing for someone who first time use command-line)
Generating a new app
cd <Where you want your app to be> mkdir express cd express // express myapp1 express --view=pug myapp1 // Using the old command above will result in security warning about jade
The "myapp1" can be replaced with other names.
Before running , use the following command to install all the dependencies.
cd <Where you want your app to be>/express/myapp1 npm install npm audit fix // Optional if there's system warning and you have paranoia
- To start the app
In Raspberry Pi or MacOSX:
cd <Where you want your app to be>/express/myapp1 [PORT=<port>] DEBUG=myapp1:* npm start
For windows
cd <Where you want your app to be>/express/myapp1 [set PORT=<port> & ]set DEBUG=myapp1:* & npm start
- Remark: the <port> should be replaced with a number between 1 and 65535, if you desire to change the port.
- Port 1~1024 is blocked from use without admin right for some system, so if you see error it might be because of this.
- Now without putting anything into the "public" folder of the app, there should be a landing page when you try to access "localhost:3000" in your browser.