react-notion-x
react-notion-x copied to clipboard
'Uncaught ReferenceError: process is not defined' error with Vite
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)
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]);
@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:
- Notion's API should not be called from client-side browsers due to CORS restrictions. notion-client is compatible with Node.js and Deno.