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.

SSR can't resolve builtin modules that start with underscore

See original GitHub issue

Describe the bug

Some packages (like @prisma/client) require the builtin _http_common module (or others that start with an underscore) which causes ssrLoadModule to throw Error: Cannot find module '_http_common' imported from ... error. It seems to be caused by the builtin-modules package that Vite uses for this purpose filtering out modules that start with an underscore (changing the relevant regex in the transpiled code fixes the problem).

Reproduction

System Info

System:
    OS: Linux 5.4 Linux Mint 20.2 (Uma)
    CPU: (8) x64 Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
    Memory: 1.70 GB / 15.53 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.18.1 - /usr/local/bin/node
    Yarn: 1.22.11 - ~/.npm-global/bin/yarn
    npm: 7.24.1 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 96.0.4664.45
    Firefox: 94.0

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
bluwycommented, Nov 25, 2021

I took a look at why @prisma/client is using _http_common, looks like it’s used by a dependency called https://github.com/nodejs/undici. From this comment, undici v4 should remove the need for _http_common, so all that’s left is for @prisma/client to upgrade to v4, which is not done yet (https://github.com/prisma/prisma/issues/7539). Maybe it’s better to wait for the PR in the long term?

2reactions
ygj6commented, Nov 25, 2021

its mentioned in #5709 that it used to work in 2.6.14

@Niputi No, I tested the above reproduction repo with vite@2.6.14 and got the same error. It is a bug of vite all the time, @bluwy is right.

In addition, I fetched your PR code and re-tested, it has solved the bug. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

jshint Error: Cannot find module 'underscore' - Stack Overflow
I can see the /grunt-contrib-jshint directory is in the /node_modules directory. Is there any reason it can't find the underscore module?
Read more >
Advanced Features: Custom `Document` - Next.js
A custom Document can update the <html> and <body> tags used to render a Page. This file is only rendered on the server,...
Read more >
@sveltejs/adapter-static - npm
Start using @sveltejs/adapter-static in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >
Shared Options | Vite
The default allowed conditions are: import , module , browser , default , and production/development based on current mode. The resolve.conditions config option ......
Read more >
Shadow CLJS User's Guide
Embedding in the JS Ecosystem — The :npm-module Target ... shadow-cljs provides several built-in variants that let you get started quickly ...
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