Loam cannot be run under Node.js
- Dominant language
- JavaScript
- Stars
- 226
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I want to use this in node.JS environment on local Windows PC, not on web browser.
Just for test, I wrote such ad-hoc code (without webpack or any packaging) and run:
```
const loam = require("loam")
loam.initialize()
const main = async () => {
const file = 'png/Nara-Genpyo.png'
const dataset = await loam.open(file)
const width = await dataset.width()
console.log(width)
}
main()
```
The result is error follow:
```
ReferenceError: self is not defined
at Object. (F:\github\loam\node_modules\loam\lib\loam.js:1:197)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (F:\github\loam\index.js:1:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
```
I changed the code like this, but still same error occurs.
```
const main = async () => {
const loam = await import("loam")
loam.initialize()
const file = 'png/Nara-Genpyo.png'
const dataset = await loam.open(file)
const width = await dataset.width()
console.log(width)
}
main()
```
Is this expected result?
Loam don't work in node.js environment or it always must be used with webpack-like packager?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the Windows Node.js example using the package entry point in index.js, then inspect the failing bundle at node_modules/loam/lib/loam.js where the self ReferenceError occurs. Verify whether both require("loam") and import("loam") reach initialize and dataset.width without the browser-only error; no test file is mentioned in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100