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.

can't require `@prefresh/babel-plugin`

See original GitHub issue

I ran into this using next-plugin-preact but I believe it’s an issue with @prefresh/babel-plugin.

I created a Next app using Preact:

❯ npx create-next-app --example using-preact next-preact-npm

And npm run dev gave me this error:

Error: Cannot find module '/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/babel-plugin/dist/src/index.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)
    at resolveExports (node:internal/modules/cjs/loader:482:14)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.mod._resolveFilename (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/next/dist/build/webpack/require-hook.js:183:28)
    at Function.Module._resolveFilename (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/module-alias/index.js:49:29)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.webpack (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/next/src/index.js:29:19)
    at Object.getBaseWebpackConfig [as default] (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/next/dist/build/webpack-config.js:1411:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/babel-plugin/package.json'

I don’t have a deep understanding of npm, but I think the problem is in packages/babel/package.json:

  "exports": {
    ".": {
      "import": "./src/index.mjs",
      "require": "./dist/src/index.js"
    },
    "./package.json": "./package.json"
  },

The require line references a file that doesn’t seem to have been installed with the package.

I have a non-Next minimal test case, which I’ll upload shortly.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JoviDeCroockcommented, Feb 20, 2022
1reaction
JoviDeCroockcommented, Feb 20, 2022

Published a fix in 0.4.3 - thanks for the report ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-refresh-webpack-plugin/TROUBLESHOOTING.md at main
A Webpack plugin to enable "Fast Refresh" (also previously known as Hot Reloading) for React components. - react-refresh-webpack-plugin/TROUBLESHOOTING.md ...
Read more >
Webpack5 + react-refresh-webpack-plugin does not work
I have been trying to setup fast refreshing and hot reloading in react with `webpack5 following the documentation for react-refresh-webpack- ...
Read more >
babel-loader - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Plugins - Babel.js
In rarer cases (if the transform isn't implemented yet, or there isn't a default way to do so), you can use plugins such...
Read more >
babel/preset-react
Automatic runtime (since v7.9.0 ) adds the functionality for these plugins automatically when the development option is enabled. If you have automatic runtime ......
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