import { Xid } from 'xid-ts'
console.log(new Xid().toString())
Compile and run:
npx tsc && node index.js
It works, and the output is the string representation of a new XID, as expected.
Now update to the latest version of XID
npm install xid-ts@1.1.3
Compile and run:
npx tsc && node index.js
The following error occurs:
(node:80703) [DEP0151] DeprecationWarning: Package /Users/matt/Code/testxid/node_modules/xid-ts/ has a "main" field set to "dist/cjs/index", excluding the full filename and extension to the resolved file at "dist/cjs/index.js", imported from /Users/matt/Code/testxid/index.js.
Automatic extension resolution of the "main" field is deprecated for ES modules.
(Use `node --trace-deprecation ...` to show where the warning was created)
file:///Users/matt/Code/testxid/index.js:1
import { Xid } from 'xid-ts';
^^^
SyntaxError: The requested module 'xid-ts' does not provide an export named 'Xid'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.11.1
In a new empty directory, setup a new TypeScript ESM project:
Install the previous version of XID:
Create an
index.ts
with the following:Compile and run:
It works, and the output is the string representation of a new XID, as expected.
Now update to the latest version of XID
Compile and run:
The following error occurs: