最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - path of require module in node js work in windows but not in linux - Stack Overflow

matteradmin7PV0评论

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'

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'

Share Improve this question edited Oct 27, 2016 at 5:07 Dave 3,0917 gold badges22 silver badges33 bronze badges asked Oct 27, 2016 at 1:49 Juan SalamancaJuan Salamanca 3544 silver badges9 bronze badges 2
  • 5 On Windows, filenames are case insensitive. On Linux, files are case sensitive. Are you sure your file is located in the proper location and is named Queries.js with that capitalization? – jfriend00 Commented Oct 27, 2016 at 2:19
  • yes, that's was the problem, thanks – Juan Salamanca Commented Dec 5, 2016 at 13:53
Add a ment  | 

2 Answers 2

Reset to default 6

Making my ment 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 mon 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.

Edit:

Verify the path to 'Queries.js'

Case 1) Assuming you have NodeJS installed, the correct syntax you are looking for is below

var queries = require('querystring');

Case 2) :However if you are referencing code in another javascript file put something similar to the below at the top of current file.

require('./Queries.js'); //Queries.js is in the current directory

or

require('./path/to/Queries.js'); //The path to Queries.js
Post a comment

comment list (0)

  1. No comments so far