1

I'm using Magde API (https://github.com/pahen/madge/blob/master/README.md) to generate the dependency graph of my JS file... Once the dependencies are return as object, the file paths are not clearly documented... I was wondering if there exists a way to tell Madge to specify the full path not the cut it

I want to get the dependencies of this file:

import * as t from 'C:/Users/Tec/todolist_example_jest/req2.js';

function formatName(user) {
  return user.firstName + ' ' + user.lastName;
}

const element = (
  <h1>
    Hello, {formatName(user)}!
  </h1>
);

const user = {
  firstName: 'Harper',
  lastName: 'Perez'
};

As we can see there exists a dependency on this file: 'C:/Users/Tec/todolist_example_jest/req2.js'; But when using madge to get the dependencies ... look below to see what is the output

Here is the code snippet:

madge('file path').then((res) => {
      dependencies = res.obj(); // the dependencies as an object
      console.log(dependencies);
});

and this is the output:

{
  '../../../../todolist_example_jest/req2.js': [],
  'simpleElement.jsx': [ '../../../../todolist_example_jest/req2.js' ]
}
../../../../todolist_example_jest/req2.js
node:fs:585
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open '../../../../todolist_example_jest/req2.js'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at C:\Users\Tec\React Native Applications\Upload-main\backend\app.js:47:27
    at Array.forEach (<anonymous>)
    at C:\Users\Tec\React Native Applications\Upload-main\backend\app.js:44:33 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: '../../../../todolist_example_jest/req2.js'
}

0 Answers0