noober noober - 6 months ago 11
Node.js Question

Is 'dot slash' (./) mandatory when a module in Node.js is required?

{6688C2CF-1A11-4AEE-B8CC-2969353B21EA}

Answer

With require('./script_name'), you can include another JS within the same folder, as you know already.

When you require('module_name') without the ./, Node.JS looks at the node_modules folder for a module with this name. Optionally, you can call it's public methods or pass it arguments.

Comments