How to Install node.js in glitch?

I am wondering how to install nodejs into glitch so I can use the require function. Right now, the require function causes an error.

Error:

Code:

const fs = require("fs");
var file = fs.readFileSync("file.json")
file = JSON.parse(file)

var body = document.body
var url = window.location.href
url = new URL(url)
var user = url.searchParams.get("userid");


body.innerHTML = file

You don’t need to install node, as it is already preinstalled.

Paste the error here.

1 Like

Can you show some code also?

const fs = require("fs");
var file = fs.readFileSync("file.json")
file = JSON.parse(file)

var body = document.body
var url = window.location.href
url = new URL(url)
var user = url.searchParams.get("userid");


body.innerHTML = file

You can’t use Node.js packages in client-side Javascript without something like webpack or browserify

3 Likes

Unless you’re page is openned in electron with node integeration :laughing:
Even with a bundler they are pretty limited and you need to make sure they don’t use anything browsers can’t do like accessing the filesystem.