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.

TypeError: Cannot read property 'tap' of undefined

See original GitHub issue

Error

I was trying your example, using this package.json (1)

{
  "name": "nextjs-preact-demo",
  "version": "1.0.0",
  "scripts": {
    "dev": "next",
    "build": "next build && next export -o build",
    "start": "NODE_ENV=production next start"
  },
  "devDependencies": {
    "@prefresh/next": "1.4.4"
  },
  "dependencies": {
    "@prefresh/webpack": "3.0.1",
    "next": "^9.5.4",
    "preact": "^10.5.7",
    "preact-render-to-string": "^5.1.4",
    "react": "npm:@preact/compat",
    "react-dom": "npm:@preact/compat",
    "react-ssr-prepass": "npm:preact-ssr-prepass@^1.0.1",
    "webpack": "^5.0.0-beta.22"
  },
  "license": "MIT"
}

And then npm run dev throws the following error:

> nextjs-preact-demo@1.0.0 dev
> next

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

ready - started server on http://localhost:3000
TypeError: Cannot read property 'tap' of undefined
    at E:\projects\js\hell\example\node_modules\@prefresh\webpack\src\index.js:78:61
    at SyncHook.eval [as call] (eval at create (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\Hook.js:154:20)
npx browserslist@latest --update-db
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

ready - started server on http://localhost:3000
TypeError: Cannot read property 'tap' of undefined
    at E:\projects\js\hell\example\node_modules\@prefresh\webpack\src\index.js:78:61
    at SyncHook.eval [as call] (eval at create (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\Hook.js:154:20)
    at Compiler.newCompilation (E:\projects\js\hell\example\node_modules\next\node_modules\webpack\lib\Compiler.js:631:26)
    at E:\projects\js\hell\example\node_modules\next\node_modules\webpack\lib\Compiler.js:667:29
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\Hook.js:154:20)
    at Compiler.compile (E:\projects\js\hell\example\node_modules\next\node_modules\webpack\lib\Compiler.js:662:28)
    at E:\projects\js\hell\example\node_modules\next\node_modules\webpack\lib\Watching.js:77:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\projects\js\hell\example\node_modules\next\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
npm ERR! code 1
npm ERR! path E:\projects\js\hell\example
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c next

Reproduction

Clone your example Replace the existing package.json by (1) Run npm i Run npm run dev

Spec

Windows 10 npm v7.5.4


Now it’s been 2 days that I’ve been trying to find the right config to run nextjs + preact (with hooks) + hot-reloading. What a pain. Anyway. 💩 Am I doing something wrong? Am I using the wrong versions? Thank you in advance for your help

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JoviDeCroockcommented, Feb 25, 2021

Hey @geisterfurz007 very much appreciated, I also worked on an error message when we are working with differing versions of webpack 😃

0reactions
geisterfurz007commented, Feb 28, 2021

Just as an update; this occurs between very wild package resolution which are not caused by this package. Storybook declares react and react-dom as dependencies which seem to be picked up by next for some reason. If I no-hoist both those packages, next doesn’t start anymore because it cannot find react which for no reason is in packages/web/node_modules instead of node_modules where react-dom sits. Either way this appears to be an issue with Yarn or Next or not sure what and not this plugin 😃

If I finally figure out how to set things up so that next and storybook work next to each other, I will update this post to maybe help someone in the future (or be able to look it up myself).
I ended up using nohoist: ["next", "next/**"] in my web package (that contains the next page) of the monorepo. This reliably makes next use the aliased packages while storybook still works with its desired actual react packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'tap' of undefined #5781
I need to install webpack for react-styleguidist, but it seems if the version doesn't match the one Next is using this error occurs....
Read more >
ProgressPlugin TypeError: Cannot read property 'tap' of ...
In my case the error was that I put a plugin under resolve.plugins , instead of directly in plugins inside the webpack config....
Read more >
Cannot read property 'tap' of undefined at HtmlWebpackPlugin ...
【Webpack】TypeError: Cannot read property 'tap' of undefined at HtmlWebpackPlugin.
Read more >
Cannot read property 'tap' of undefined in ts-loader #14157
Describe the bug. Module build failed (from ./node_modules/ts-loader/index.js): TypeError: Cannot read property 'tap' of undefined. To Reproduce ...
Read more >
Cannot read property 'tap' of undefined-Reactjs - appsloveworld
[Solved]-React- Webpack: Cannot read property 'tap' of undefined-Reactjs ... I had the same exact problem. You have to add @babel/preset-react library to your ......
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