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

i have this in my code var queries = require('.Queries.js');when start the node server in wi

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745662064a4638896.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信