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

ENOENT 'stealconfig.js' on node/Windows when configMain is not specified #1552

Open
1 of 5 tasks
bmomberger-bitovi opened this issue Feb 14, 2023 · 0 comments
Open
1 of 5 tasks

Comments

@bmomberger-bitovi
Copy link
Contributor

bmomberger-bitovi commented Feb 14, 2023

How often can you reproduce it?

  • Always
  • Sometimes
  • Rarely
  • Unable
  • I didn’t try

Description:

Steps to reproduce:

In a node process,

  • set up window, document, etc. on global using a JSDOM instance
  • Do not have a stealconfig.js in your root dir
  • call steal.startup() with a main defined but no configMain

Expected results:

  • no error,
  • configMain in the steal instance is set to "package.json!npm" (which is consistent with what happens on MacOS or Linux platforms)

Actual results:

  • process exits with the following error
[Error: ENOENT: no such file or directory, open '<drive>:\<path to project>\stealconfig.js'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: '<drive>:\\<path to project>\\stealconfig.js',
  statusCode: 404,
  url: 'file:<drive>:/<path to project>/stealconfig.js'
}
  • if breaking in with a debugger before the error, configMain is set to stealConfig.js

Deep analysis:

steal/main.js line 2241: getUrlOptions() sets a default stealPath to __dirname, which uses backslashes on windows

this is a problem when we get to specialConfig.stealPath.set(), line 1995 or so, because parts has been created by splitting dirname (which is envPath(stealPath)) on "/", line 1971. This makes the test after isNode fail because it's not getting the last path element correctly

There's only two places I see backslashes being replaced with forward slashes:

  • function core(), line 2683, where an isWindows check and a (not working check due to us setting window on global) is setting baseUri
  • toAbsoluteURL line 2503 where it will change the href before reconstructing and returning it

so isWindows is declared both on lines 2467 and 4737. that doesn't cover either of the scopes where it may be needed.
I think it comes down to fixing the appropriate source files. I just don't know

In the meantime, setting configMain manually to "package.json!npm" when configuring should provide a workaround.

Environment:

Software Version
Steal version 2.3.0
Steal-tools version N/A
node -v 14.21.2
npm -v 6.14.17
Browser JSDOM
Operating system Windows 10
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

1 participant