redactuk's avatar

Usage of 'require' in js source files

Hi folks

Noob question incoming....

Am I correct in thinking that require('myfile') is handled entirely differently simply based on whether or not you specify an alternative directory e.g. require('.../myfile') will look for JS myfile in the parent directory, whereas require('myfile') will instead look for a npm package? If this is the case how do you require your own JS file in the same directory as app.js or do you always have to place stuff one directory higher or lower to avoid a node_modules lookup?

0 likes
2 replies

Please or to participate in this conversation.