What is the difference between __dirname and ./ in node.js?

The gist In Node.js, __dirname is always the directory in which the currently executing script resides (see this). So if you typed __dirname into /d1/d2/myscript.js, the value would be /d1/d2. By contrast, . gives you the directory from which you ran the node command in your terminal window (i.e. your working directory) when you use libraries like path and fs. Technically, it starts out as your working directory … Read more

How do I resolve “Cannot find module” error using Node.js?

Using npm install installs the module into the current directory only (in a subdirectory called node_modules). Is app.js located under home/dave/src/server/? If not and you want to use the module from any directory, you need to install it globally using npm install -g. I usually install most packages locally so that they get checked in along with my project code. … Read more

What is Express.js?

This is over simplifying it, but Express.js is to Node.js what Ruby on Rails or Sinatra is to Ruby. Express 3.x is a light-weight web application framework to help organize your web application into an MVC architecture on the server side. You can use a variety of choices for your templating language (like EJS, Jade, and Dust.js). You can then use a database like MongoDB with Mongoose (for modeling) to provide … Read more

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