Comments (5)
I ran into this error too, the BullMQ method that @Curetix mentions seems to hold a clue; the method's comment references a discussion on stack overflow which states;
Node publishes all the module search paths to module.paths. We can traverse these and pick the first one that resolves.
It would appear that Bun follows this behavior only when running.
When building/compiling the 'module' global seems to be replaced somehow, which suggests to me it may not be recognized or set as a global.
A simple test file confirms this;
// index.ts
console.log(module.paths);
When launched with bun run
this will produce an array output.
When built via bun build --target bun --outfile out.js index.ts
and subsequently run via bun run out.js
this produces undefined
.
@knajjars I suggest you change the title of your bug report so to something like module.paths not set when using bun build
- surely there will be modules other than BullMQ suffering from this bug.
EDIT: There seems to be a bit more to it; apparently this is caused by BullMQ using the module.paths
to dynamically load Lua files onto the Redis instance, which would hide these files from the Bun bundler. These would need to be turned into assets by the bundler somehow.
from bun.
I'm getting the same error from a bundled BullMQ server script. Running the TS file directly works fine, but building (with target bun) and then running it throws ReferenceError: Can't find variable: module_script_loader
.
Seems to be caused by this function, which gets bundled to this:
var getPkgJsonDir = function() {
for (const modPath of module_script_loader.paths || []) {
try {
const prospectivePkgJsonDir = path3.dirname(modPath);
fs2.accessSync(modPath, fs2.constants.F_OK);
return prospectivePkgJsonDir;
} catch (e) {
}
}
return "";
};
from bun.
Any news on this ?
from bun.
Same error
from bun.
Using --compile
I get:
ReferenceError: Can't find variable: module_script_loader
at getPkgJsonDir (/$bunfs/root/cli:46442:25)
at new ScriptLoader (/$bunfs/root/cli:46509:21)
at /$bunfs/root/cli:46722:20
from bun.
Related Issues (20)
- Bun shell $.split
- Can not get element compued styles in test
- Enchanced/clear/suggested proxy or REGISTRY/mirror setting in Windows, especially in Windows PowerShell. HOT 1
- Completion: Support Tab completion for arguments in powershell
- Illegal instruction at address 0x7ff7ccff5671, a core dump
- jest-dom matcher types not being set automatically
- memory leak issues with in memory cache libraries like `node-cache` or `lru-cache` HOT 1
- Bun doesn't ensure "devDependencies" are installed when running "prepare" script
- panic: reached unreachable code (bun pm trust) HOT 3
- Workspace: "bun --filter './packages/NAME' SCRIPT_NAME PARAM_VALUE" Module/Script not found HOT 2
- Code works in Node.js but doesn't in Bun HOT 2
- Support `"file://…"` for paths passed to `dlopen(…)` (from `bun:ffi`) HOT 2
- Bun shell convert named columns to json HOT 1
- wasm-simd is not supported in bun HOT 1
- Bun 10x slower while running OCR HOT 1
- Run different scripts from different workspaces in monorepo in parallel
- "sub-dependencies" not installed correctly HOT 2
- Selecting options during bun create only works when NodeJS is also installed. HOT 1
- Problems in --filter first implementation HOT 1
- Bun REPL crashes when inspecting a result
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bun.