0

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)

5
  • 1
    Are you going up enough paths? Might need to do ../../folder1/folder2/a.js Commented Dec 12, 2016 at 17:24
  • 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 Commented Dec 12, 2016 at 17:24
  • You just got the path wrong. Commented Dec 12, 2016 at 17:59
  • 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 Commented Dec 12, 2016 at 18:15
  • Just read up on relative paths. Commented Dec 15, 2016 at 12:52

1 Answer 1

0

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

Error: Cannot find module '

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.