SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.21k stars 662 forks source link

Custom component Error: STACK does not have a file url. Check out if the node version >= 8 #388

Closed stelone closed 4 years ago

stelone commented 4 years ago

Describe the bug Error Error: STACK does not have a file url. Check out if the node version >= 8 when I try to load a custom component.

Installed libraries and their versions

To Reproduce Steps to reproduce the behavior:

  1. Add custom resources
    {
    options: {
    properties: {
      submodel: {
        component: {
          new: AdminBro.bundle('./admin-bro/SubModel.tsx'),
        }
      }
    }
    }
    }

Expected behavior AdminBro.bundle generate an error : UnhandledPromiseRejectionWarning: Error: STACK does not have a file url. Check out if the node version >= 8. Same for AdminBro.require.

Desktop:

Additional context I inspect a code of AdminBro.bundle, and I see :

    if (src[0] === '/') {
      filePath = src;
    } else {
      const stack = (new Error().stack || '').split('\n');
      const m = stack[2].match(/\((.*):[0-9]+:[0-9]+\)/);

      if (!m) {
        throw new Error('STACK does not have a file url. Check out if the node version >= 8');
      }

      filePath = path.join(path.dirname(m[1]), src);
    }

stack[2] is equal to at C:\Users\...\src\server\Routers\AdminRouter.ts:198:43

wojtek-krysiak commented 4 years ago

I think it is related to #364 - can you downgrade node to v10 and see if that works?

stelone commented 4 years ago

Ok so I downgrade to v10 and it's working like a charm. This is a little annoying... my production server is on v12. v12 is the recommanded version.

wojtek-krysiak commented 4 years ago

yep I know - this issue will be fixed sooner rather than later

wojtek-krysiak commented 4 years ago

duplicates #364

wojtek-krysiak commented 4 years ago

duplicates #364