Search code examples
javascriptnode.jsmodulepathrequire

path of require module in node js work in windows but not in linux


i have this in my code

var queries = require('./Queries.js');

when start the node server in windows cmd is ok.

I clone the proyect in a linux ec2 server , but when i start the server not works

Error: Cannot find module './Queries.js'


Solution

  • Making my comment into an answer since this seems to have been your issue:

    On Windows, filenames are case insensitive. On Linux, files are case sensitive. This is a common platform difference for anyone writing cross platform code for these two platforms.

    So, make sure your file is located in the proper location and is named Queries.js with that exact capitalization.

    I generally find it best to just never use mixed case (always all lowercase) in programming filenames and then you never have this issue.