Preamble
I'm very new to parcel and using bundlers so I could be doing something completely wrong.
I followed the guidance provided at Building a library with Parcel since I am trying to bundle the server-side code which will be executed by node.js
My package.json contains the following(removed uneccessary details):
{
"source":"bin/server.js",
"module":"dist/server.js"
"scripts":{
"build": "parcel build"
}
"type":"module"
}
Main Problem
When I build my application with npm rum build it generates everything just fine, no errors are thrown and it only takes about 2 seconds.
Then when I try to run the application with "node .\bin\server.js" it throws the following error.
import {exit as $a7IyA$exit, on as $a7IyA$on} from "process";
------------------------------^^--------------------------------------------------
SyntaxError: The requested module 'process' does not provide an export named 'on'
For additional context, the application does run as expected before I bundle with parcel and the server.js file does include the following as the first import (where error is thrown).
import {exit as $a7IyA$exit, on as $a7IyA$on} from "process";
Update:
After reviewing the Targets documentation, this does make me more confident that Parcel can be used for backend bundling and I tried updating my package.json to the following:
{
"targets": {
"server": {
"source": "bin/server.js",
"context": "node",
"distDir": "./dist",
"includeNodeModules": true,
"outputFormat": "esmodule"
}
},
"scripts":{
"build": "parcel build"
}
"type":"module"
}
This did get me further, but I'm now getting the following error:
Uncaught ReferenceError ReferenceError: $2az4q$relative is not defined