I have been playing around with this for quite a few hours now. I have a web application, and I need to use node modules, as I have done many times in the past. This time I need to host my application and I am using Vercel to do so. The application is a personal project of one page. I have had no troubles except for when importing modules in a .js file. My code for importing is as follows:
import { process } from './node_modules/process';
I have tried these other ways to import it:
- Using
require('node_module')
- Turning the
.js
file into a.mjs
file - Adding
type='module'
into the relevant script tag - Using a seperate
.mjs
file and importing the there then exporting and importing into the main.js
file.
The way I have currently is the way I would expect it to work normally, however I get this error when importing: See image for error
Anyone have any ideas? I looked into the idea it might be a GitHub Pages/Vercel issue with node, but nothing was relevant to the issue