NodeJS / Express: what is “app.use”?

The app object is instantiated on creation of the Express server. It has a middleware stack that can be customized in app.configure()(this is now deprecated in version 4.x). To setup your middleware, you can invoke app.use(<specific_middleware_layer_here>) for every middleware layer that you want to add (it can be generic to all paths, or triggered only on specific path(s) your server handles), … Read more

Significance of port 3000 in Express apps

3000 is a somewhat arbitrary port number chosen because it allows you to experiment with express without root access (elevated privilege). Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments. Using port 3000 in examples also helps indirectly emphasize that you ideally want to put your express app behind nginx or Apache httpd or … Read more

How to change to an older version of Node.js

One way is to use NVM, the Node Version Manager. Use following command to get nvm You can find it at https://github.com/creationix/nvm It allows you to easily install and manage multiple versions of node. Here’s a snippet from the help:

How to downgrade Node version

Warning: This answer does not support Windows OS You can use n for node’s version management. There is a simple intro for n. this is very easy to use. then you can show your node version: For windows nvm is a well-received tool.

How can I wait In Node.js (JavaScript)? l need to pause for a period of time

Update Jan 2021: You can even do it in the Node REPL interactive using –experimental-repl-await flag A new answer to an old question. Today ( Jan 2017 June 2019) it is much easier. You can use the new async/await syntax. For example: For using async/await out of the box without installing and plugins, you have to use node-v7 or node-v8, using the –harmony flag. Update June … Read more

Angular – ng: command not found

I’m trying to learn Angular and my knowledge in terminal is beginner. After I installed Angular and then type ng new my-project. I get the response ng: command not found. I’ve seen other posts that had this problem and I’ve uninstalled and reinstalled npm and ng. The last step I took was npm install -g @angular/cli@latest then ng new my-project. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)