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 resolve 'http2'`for React & `Can't resolve 'dns'` for Next,js

See original GitHub issue

I want to use the Notion API. Can these be used in React? I wrote it like this.

import { Client } from '@notionhq/client';

function App() {
  const notion = new Client({ auth: process.env.REACT_APP_INTEGRATION_TOKEN });
  return (
    <div className="App">
    // ...more

In Next.js, Module not found: Can't resolve 'dns'. In CRA, Module not found: Can't resolve 'http2'. is displayed.

package.json

{
  "name": "lesson-notion-api",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@notionhq/client": "^0.1.3",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
aoberoicommented, May 15, 2021

Thanks for describing what you’re hoping to accomplish. At this time, this project doesn’t support what you’ve described. But it might be something we add! Let’s discuss it over in #60. I’m going to close this issue so I can funnel several discussions together.

2reactions
janzhengcommented, Jun 21, 2021

Using this on the Svelte client, getting same error. No problem running in server-side using Sapper.

Edit: not sure why discussions are all deleted, but turns out notion client can’t be used in a browser / client-side. Would be really helpful if that was added to the official documentation @aoberoi

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve 'dns' in '/Users/Austin ...
I've run into the same issue. The message is not super helpful but it means you are trying to run node.js/server side code...
Read more >
module-not-found - Next.js
Possible Ways to Fix It. The module you're trying to import is not installed in your dependencies. When importing a module from npm...
Read more >
Node.js v19.3.0 Documentation
Called when the resolve function passed to the Promise constructor is invoked (either directly or through other means of resolving a promise). resolve()...
Read more >
Using HTTP/2 with Next.js & Express - ITNEXT
Next.js is a famous server-side rendering framework using Node.js and React to produce fast, pre-rendered and optimized React-based websites or web ...
Read more >
How to Enable Server-Side Rendering for a React App
Step 2 — Creating an Express Server and Rendering the App Component · Express is used to serve contents from the build directory...
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