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.

Cannot find module happy-wrapper

See original GitHub issue

I got this error when I upgraded vite-plugin-md to 0.17.x in my vitesse project.

failed to load config from /Users/xxx/Work/Vue/vitesse/vite.config.ts
error when starting dev server:
Error: Cannot find module '/Users/xxx/Work/Vue/vitesse/node_modules/.pnpm/vite-plugin-md@0.17.4_wie7zz22o3tz6qyv6muewmoury/node_modules/@yankeeinlondon/happy-wrapper/dist/index.cjs'
    at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)
    at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
    at resolveExports (internal/modules/cjs/loader.js:450:14)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/xxx/Work/Vue/vitesse/node_modules/.pnpm/vite-plugin-md@0.17.4_wie7zz22o3tz6qyv6muewmoury/node_modules/vite-plugin-md/dist/index.js:11869:28)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)

Steps:

  1. clone vitesse
  2. upgrade vite-plugin-md to 0.16.x or 0.17.x
  3. run pnpm dev

reproduction

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
yankeeinlondoncommented, Jun 24, 2022

Hi folks, sorry been trying to ensure that everything is ESM and CJS compliant and I think there were a few bumps.

For context, I’m trying to make sure that the dependency stack works for ESM fully (it has not in the past) and there are a few packages which Vite seems to take issue with:

  • fp-ts - it has an ESM implementation but the way it’s done is awkward and Vite doesn’t work well with it so I’ve made the use of this dependency explicit and rolled and shaken into the actual vite-plugin-md; adds a tiny bit to the bundle size but it just works this way so worth the additional payload
  • markdown-it - it has no ESM implementation (if I remember correctly) so I’ve pushed it into being a top-level dependency of consumers by making it a peer dependency. Being a top-level dependency allows the bundler to consume the CJS and convert to ESM if the consumer is using ESM (and leave it as-is if consumer is CJS).

With happy-wrapper there is yet another issue with ESM … and that isn’t directly to do with happy-wrapper but the happy-dom implementation which Vite can handle when a top level dependency but not otherwise. I’m not sure I have fully understood this yet but I had thought by making happy-wrapper an ESM export only that I might be able to avoid this. Based on the issues folks are having though I can see there’s a little more tuning to be done.

Sorry for the inconvenience. ESM will be a great world once we’re finally there but the journey has a lot of little potholes along it. Anyway, just woke up but i’ll get a patch in for this today and it sounds like others have found a work-around for now.

1reaction
kecrilycommented, Jun 24, 2022

Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘markdown-it’ imported from /usr/local/playground/@codermar/monorepo/marynela.com/node_modules/.pnpm/vite-plugin-md@0.17.4_vite@2.9.12+vue@3.2.37/node_modules/vite-plugin-md/dist/index.mjs

@Codermar Now markdown-it is a peerDependencies, so you need install it in your project.

"peerDependencies": {
  "vite": "^2.9.9",
  "markdown-it": "^13.0.1"
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >
Can't find module 'hapi' · Issue #1 · dwyl/learn-hapi - GitHub
When I try to run my first completed challenge "makemehapi run program.js" I get this error. But I installed hapi with 'npm install...
Read more >
Cannot find module wrappy npm installation - How to fix it
Cannot find module wrappy npm installationis an error caused by by diffierent version of NPM installed. To fix it follow the given steps....
Read more >
vite exports is not defined | The AI Search Engine You Control
tryNodeResolve fails on Firebase. It swallows this exception from _resolveExports inside resolveExports : Missing "." export in "firebase" package. It seems ...
Read more >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
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