0
votes

I want to use /folder1/folder2/a.js in /folder3/folder4/b.js.

In b.js, i tried

var a = require('../folder1/folder2/a.js');

but this is not working. Please suggest me the correct way to do this.

error:module.js:471
    throw err;
    ^ 

> Error: Cannot find module '../folder1/folder2/a.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (C:\Users\502660706\workspace\folder3\folder4\b.js:1:85) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)

1
Are you going up enough paths? Might need to do ../../folder1/folder2/a.js - Stephen
Could you please include the output of the following commands (to make sure this is not a pathing issue): ls ../ ls ../folder1 ls ../folder1/folder2 - Benjamin Dean
You just got the path wrong. - Robert Moskal
Thanks Stephen. This worked. I tried var tjConnectorNode = require('../../../workspace/folder1/folder2/a.js'); i dont know how it is considering the path. I just tried and its working. Can anyone explain me how this works - veenasa
Just read up on relative paths. - Robert Moskal

1 Answers

0
votes

according to the output message you're giving a wrong path of the file.

Error: Cannot find module '