Skip to content

Instantly share code, notes, and snippets.

@janpauldahlke
Created July 22, 2024 13:27
Show Gist options
  • Save janpauldahlke/de294a0bb3178564cb627c6dc9435b89 to your computer and use it in GitHub Desktop.
Save janpauldahlke/de294a0bb3178564cb627c6dc9435b89 to your computer and use it in GitHub Desktop.
consume ts only module from jsr
import { isOdd } from "@hail-discordia/is-odd-ts";
export function main() {
console.log(isOdd(2))
}
main()
// i used this here, where one can see the source. maybe the error is occuring in me publishing it wrong?
// tried `tsc main.ts` which gives me a `main.js` but `node main.js` results in this error:
//
```shell
Node.js v18.18.2
➜ consume-ts-is-odd node main.js
file:///Users/hagbard/dev/consume-ts-is-odd/main.js:2
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/hagbard/dev/consume-ts-is-odd/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/jdahlke/dev/consume-ts-is-odd/main.js:2:23
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)```
{
"name": "consume-ts-is-odd",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@hail-discordia/is-odd-ts": "npm:@jsr/hail-discordia__is-odd-ts@^0.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment