pkl-community / pkl-typescript

TypeScript language bindings for the Pkl programming language
https://www.npmjs.com/package/@pkl-community/pkl-typescript
Apache License 2.0
104 stars 1 forks source link

Error: Using recent changes, when running 'npx pkl-gen-typescript' I get error: "Unknown file extension ".ts"" #32

Closed PaulJPhilp closed 8 months ago

PaulJPhilp commented 8 months ago

I cloned the pkl-typescript repo to get most recent changes.

I run the command: npx pkl-gen-typescript pklState/Event.pkl -o pklState/typescript

I get the following error:

node:internal/modules/esm/get_format:160

throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath); ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/paul/projects/pkl-typescript/bin/pkl-gen-typescript.ts at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9) at defaultGetFormat (node:internal/modules/esm/get_format:203:36) at defaultLoad (node:internal/modules/esm/load:143:22) at async ModuleLoader.load (node:internal/modules/esm/loader:409:7) at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45) at async link (node:internal/modules/esm/module_job:76:21) { code: 'ERR_UNKNOWN_FILE_EXTENSION' }

Node.js v20.11.1

jasongwartz commented 8 months ago

This is probably a mismatch from the recent commit that changed the entrypoint to dist (in prep for distributing as an npm package).

I’ll try to replicate soon and get back to you, thanks for reporting!

PaulJPhilp commented 8 months ago

Thanks. I just remembered that I made a change to the package.json file. I added "type: module". I did this to resolve an earlier error:

(node:63212) Warning: To load an ES module, set "type": "module" in the

package.json or use the .mjs extension. (Use node --trace-warnings ... to show where the warning was created) /Users/paul/projects/pkl-typescript/bin/pkl-gen-typescript.ts:2 import pklGenTypescript from "../pkl-gen-typescript/main"; ^^^^^^

SyntaxError: Cannot use import statement outside a module

at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain]

(node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49

On Sun, Mar 17, 2024 at 8:32 PM Jason Gwartz @.***> wrote:

This is probably a mismatch from the recent commit that changed the entrypoint to dist (in prep for distributing as an npm package).

I’ll try to replicate soon and get back to you, thanks for reporting!

— Reply to this email directly, view it on GitHub https://github.com/pkl-community/pkl-typescript/issues/32#issuecomment-2002684099, or unsubscribe https://github.com/notifications/unsubscribe-auth/BA6V6ZTOEDQ7YK5XNMHW5HTYYYY3VAVCNFSM6AAAAABE2TIKXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGY4DIMBZHE . You are receiving this because you authored the thread.Message ID: @.***>

jasongwartz commented 8 months ago

@PaulJPhilp We've just started publishing releases to NPM, would you please try uninstalling the git dependency (or npm link) and re-installing using npm i @pkl-community/pkl-typescript? Then you should be able to use npx pkl-gen-typescript as expected. Let me know if it works!

PaulJPhilp commented 8 months ago

Yes, it works!

Thank you.

Back to work.

Paul

On Sat, Mar 30, 2024 at 8:10 AM Jason Gwartz @.***> wrote:

@PaulJPhilp https://github.com/PaulJPhilp We've just started publishing releases to NPM, would you please try uninstalling the git dependency (or npm link) and re-installing using npm i @pkl-community/pkl-typescript? Then you should be able to use npx pkl-gen-typescript as expected. Let me know if it works!

— Reply to this email directly, view it on GitHub https://github.com/pkl-community/pkl-typescript/issues/32#issuecomment-2028030636, or unsubscribe https://github.com/notifications/unsubscribe-auth/BA6V6ZQCOLXMNYL7QXHF36LY22TVFAVCNFSM6AAAAABE2TIKXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYGAZTANRTGY . You are receiving this because you were mentioned.Message ID: @.***>

jasongwartz commented 8 months ago

Glad to hear! Thanks again for being an early tester 🙏