Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raonsol opened this issue Jul 17, 2023 · 2 comments
Open

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

raonsol opened this issue Jul 17, 2023 · 2 comments

Comments

@raonsol
Copy link

raonsol commented Jul 17, 2023

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
Copy link

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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants