NotionX / react-notion-x

Fast and accurate React renderer for Notion. TS batteries included. ⚡️
https://react-notion-x-demo.transitivebullsh.it
MIT License
4.69k stars 544 forks source link

'Uncaught ReferenceError: process is not defined' error with Vite #509

Open raonsol opened 1 year ago

raonsol commented 1 year ago

Description

Enviroment: Vite + Typescript + SWC

When I tried to create new NotionAPI object, vite throws an error.

import { NotionAPI } from "notion-client";
const notion = new NotionAPI();
// Uncaught ReferenceError: process is not defined

I think it is related with package @szmarczak/http-timer, which uses code that implicitly gets node version by process.versions.node. Vite does not allow importing env variables with process object. (https://vitejs.dev/guide/env-and-mode.html)

GEOkettle commented 2 months ago

any chance you solved this problem? I faced same one and I tried npm install node-libs-browser and import it in notion-client.js but didn't work. it passed first error point but occured at below line var nodejsMajorVersion = Number(process.versions.node.split(".")[0]);

GEOkettle commented 2 months ago

@raonsol FYI, I tried to solve it with Pollypill and managed it but that wasn't a problem. even if you solve that problem you would face the CORS issue. this "process" and "CORS" occurred because we tried to call the notion's API from the client side so I installed notion-client on the node side and it worked fine

DOC says: