question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent SSR require/import paths on Windows

See original GitHub issue

Describe the bug

The following entries appear in require.cache on Windows…

[
  'C:\\DevTemp\\my-app\\node_modules\\solid-js\\web\\dist\\server.cjs',
  'C:/DevTemp/my-app/node_modules/solid-js/dist/server.cjs',
  'C:\\DevTemp\\my-app\\node_modules\\solid-js\\dist\\server.cjs'
]

Note the 2nd and 3rd paths above refer to the same file.
Whereas on Linux in the same project we see…

[
  '/home/brendan/devtemp/my-app/node_modules/solid-js/web/dist/server.cjs',
  '/home/brendan/devtemp/my-app/node_modules/solid-js/dist/server.cjs'
]

The second entry results from a require() call within the preceding .cjs file. Whereas the others result from Vite calling its dynamicImport() function.

On Windows the duplication of the second and third import above results in errors in this particular library as it is expected to run once.

These were observed by calling console.log(Object.keys(require.cache).filter(k => k.includes("solid-js"))) in strategic locations on both OSs.

Reproduction

mkdir my-app
cd my-app
npm init solid@next  (choose Typescript)
npm install
npm run dev

Browse http://localhost:3000/ and observe an error (on Windows only).

Add this console log somewhere: console.log(Object.keys(require.cache).filter(k => k.includes("solid-js"))) eg. line 67385 of node_modules\vite\dist\node\chunks\dep-3daf770c.js

    try {
        const mod = await dynamicImport(url);
        console.log(Object.keys(require.cache).filter(k => k.includes("solid-js")))
        return proxyESM(mod);
    }
    finally {
        unhookNodeResolve();
    }

Observe the above mentioned require.cache entries differ from Windows to Linux.

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 5.52 GB / 15.72 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (96.0.1054.43)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vite: ^2.7.1 => 2.7.1

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Brendan-cselcommented, Jan 18, 2022

This issue seems to be resolved in 2.7.13. Thanks to all involved!

1reaction
patak-devcommented, Jan 19, 2022

Thank you @Brendan-csel for all the testing in the issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Node.js require vs. ES6 import/export - Stack Overflow
Babel converts import and export declaration to CommonJS ( require / module.exports ) by default ... Linux, Mac, Windows) to load JavaScript file/module....
Read more >
import - JavaScript - MDN Web Docs - Mozilla
Named and default imports are distinct syntaxes in JavaScript modules. Default import. Default exports need to be imported with the ...
Read more >
Troubleshooting Common Errors - Gatsby
The following errors are related to styles in your site, using CSS, preprocessors, or CSS-in-JS solutions. Inconsistent CSS styles between develop and build ......
Read more >
Resolve validation errors - Azure DevOps Services
Fix errors reported upon importing a process to support customization of tracking work in Azure DevOps Services.
Read more >
Troubleshoot designer component errors - Azure Machine ...
The component requires that data be categorical but your data is numeric. The data is in the wrong format. Imported data contains invalid ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found