Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on __dirname #18

Closed
kuraga opened this issue Oct 4, 2018 · 15 comments
Closed

Error on __dirname #18

kuraga opened this issue Oct 4, 2018 · 15 comments

Comments

@kuraga
Copy link

kuraga commented Oct 4, 2018

(node:12505) UnhandledPromiseRejectionWarning: Error: Could not load node-globals:dirname (imported by /home/sasha/rotorjs/node_modules/tman/lib/tman.js): Path must be a string without null bytes
    at /home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:21724:19
    at <anonymous>

Any thoughts?

@calvinmetcalf
Copy link
Owner

how are you using this ?

@kuraga
Copy link
Author

kuraga commented Oct 5, 2018

@calvinmetcalf tman does

@calvinmetcalf
Copy link
Owner

is it being included in your rollup configs ?

@kuraga
Copy link
Author

kuraga commented Oct 5, 2018

@calvinmetcalf what do you mean?

Error disappears since I remove __dirname from that line.

@calvinmetcalf
Copy link
Owner

this is a plugin for rollup, depending on your config when building your thing it may or may not be included in your build and thus error out

@kuraga
Copy link
Author

kuraga commented Oct 5, 2018

UPDATED:

@calvinmetcalf ,
rollup-node-globals-issue.zip,
node build.js.

@calvinmetcalf
Copy link
Owner

calvinmetcalf commented Oct 5, 2018 via email

@kuraga
Copy link
Author

kuraga commented Oct 5, 2018

@calvinmetcalf , then:

Error: 'default' is not exported by node_modules/tman/lib/tman.js
    at error (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:3460:30)
    at Module.error (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:13361:9)
    at handleMissingExport (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:13048:21)
    at Module.traceVariable (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:13469:17)
    at ModuleScope.findVariable (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:12723:29)
    at MemberExpression$$1.bind (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:11244:50)
    at CallExpression.NodeBase.bind (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:9183:23)
    at CallExpression.bind (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:10234:31)
    at ExpressionStatement$$1.NodeBase.bind (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:9183:23)
    at Program.NodeBase.bind (/home/sasha/rotorjs/node_modules/rollup/dist/rollup.js:9179:31)

But it does...

@kuraga
Copy link
Author

kuraga commented Oct 5, 2018

@calvinmetcalf Hm, interesting facts (on original code):

  1. If code is import tman as tman; tman.run(); - we have an error.
  2. If code is import tman as tman; tman.run(); and we remove __dirname here, - we don't have an error.
  3. If code is import tman as tman; - we still have __dirname (and it's assignment) in the bundle but don't have an error!

@kuraga
Copy link
Author

kuraga commented Oct 8, 2018

@calvinmetcalf but what does this error mean? Where does it come from? The error. Forget the context.

@calvinmetcalf
Copy link
Owner

the original error has to do with it not being able to find the stand in module we use for __dirname, not sure why...

@kuraga
Copy link
Author

kuraga commented Oct 19, 2018

@calvinmetcalf , got part of this issue.

  1. Original:
    a. Plugins order: resolve, commonjs, globals (and builtins)
    b. ECMAScript modules? Yes.
    c. Result: Error: Could not load node-globals:dirname (imported by /home/sasha/rotorjs/node_modules/tman/lib/tman.js): Path must be a string without null bytes.

  2. Trying A:
    a. Plugins order: globals (and builtins), resolve, commonjs.
    b. ECMAScript modules? Yes.
    c. Result: Error: 'default' is not exported by node_modules/tman/lib/tman.js.

  3. Trying B:
    a. Plugins order: globals (and builtins), resolve, commonjs.
    b. ECMAScript modules? No (building script.js instead of script.mjs, see here).
    c. Result: success!

  4. Trying C:
    a. Plugins order: resolve, commonjs.
    b. ECMAScript modules? Yes.
    c. Result: no errors but unresolved symbols.

So, you were right:

put globals before resolve in your config

But this plugins order is incompatible (in my code) with ESM... And ESM works fine without your plugin.

@kuraga
Copy link
Author

kuraga commented Oct 19, 2018

@calvinmetcalf ahaha, I got it!!! We have a new error since I set correct plugins order. See #20 , please!

@kuraga
Copy link
Author

kuraga commented May 25, 2019

Null byte (\0) is really in these lines. It was introduced in #3 .

@kuraga
Copy link
Author

kuraga commented May 25, 2019

Ah, ok, close in favor of #23 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants