Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown file extension ".ts" #218

Closed
Thykof opened this issue Jun 19, 2023 · 6 comments
Closed

Unknown file extension ".ts" #218

Thykof opened this issue Jun 19, 2023 · 6 comments
Assignees

Comments

@Thykof
Copy link
Contributor

Thykof commented Jun 19, 2023

Describe the bug
A clear and concise description of what the bug is.

npm run deploy fails with error

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/nathanmassa/dev/test-toolkit/deploy-dns/src/deploy.ts
    at new NodeError (node:internal/errors:399:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:139:38)
    at defaultLoad (node:internal/modules/esm/load:83:20)
    at nextLoad (node:internal/modules/esm/hooks:735:28)
    at load (/Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/ts-node/dist/child/child-loader.js:19:122)
    at nextLoad (node:internal/modules/esm/hooks:735:28)
    at Hooks.load (node:internal/modules/esm/hooks:380:26)
    at MessagePort.handleMessage (node:internal/modules/esm/worker:165:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'

To Reproduce

Create a new project with the initializer, run npm run deploy

Expected behavior
A clear and concise description of what you expected to happen.

it should execute the script src/deploy.ts

Screenshots
If applicable, add screenshots to help explain your problem.

Versions
The versions of software and packages the bug in present in (massa-as-sdk, toolkit, Thyra, web browser...)

0.5.0

node: v20.2.0
npm: 9.6.6
OS: mac M1 (arm)

Additional context
Add any other context about the problem here.

I have found a workaround:

node --loader ts-node/esm src/deploy.ts

but I have another error:

Wallet Address: AU1wN8rn4SkwYSTDF3dHFY4U28KtsqKL1NnEjDZhHnHEy6cEQm53 has balance (candidate, final) = (499.98975, 499.98975)
Sending operation with 100000000 MAS coins...
/Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/@massalabs/massa-web3/dist/cmd/web3/BaseClient.js:170
                error: new Error(responseData.error.message),
                       ^

Error: Parsing error: signature bs58_check parsing error: [0, 59, 189, 139, 90, 228, 72, 215, 199, 119, 169, 132, 95, 193, 222, 125, 224, 148, 45, 45, 135, 52, 203, 219, 19, 234, 27, 226, 230, 8, 171, 204, 71, 212, 73, 212, 182, 160, 91, 119, 1, 49, 79, 235, 218, 13, 155, 209, 182, 62, 125, 214, 199, 50, 234, 161, 28, 192, 34, 192, 42, 73, 76, 50, 12] at line 1 column 100243
    at SmartContractsClient.promisifyJsonRpcCall (/Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/@massalabs/massa-web3/dist/cmd/web3/BaseClient.js:170:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SmartContractsClient.sendJsonRPCRequest (/Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/@massalabs/massa-web3/dist/cmd/web3/BaseClient.js:191:16)
    at async SmartContractsClient.deploySmartContract (/Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/@massalabs/massa-web3/dist/cmd/web3/SmartContractsClient.js:90:23)
    at async deploySC (file:///Users/nathanmassa/dev/test-toolkit/deploy-dns/node_modules/@massalabs/massa-sc-deployer/dist/index.js:202:18)
    at async file:///Users/nathanmassa/dev/test-toolkit/deploy-dns/src/deploy.ts:20:5

tell me if it requires another issue for this error or if it's related

@qdrn
Copy link
Member

qdrn commented Jul 10, 2023

Same issue here.

❯ node --version
v20.3.1
❯ npm --version
9.6.7

Maybe we can add this test to the CI ?

@Thykof
Copy link
Contributor Author

Thykof commented Nov 15, 2023

My workaround is to compile and run with node: npx tsc && node src/deploy.js.

Edit: not the best workaround

@Thykof
Copy link
Contributor Author

Thykof commented Nov 15, 2023

another better workaround: node --loader ts-node/esm src/deploy.ts

@Thykof
Copy link
Contributor Author

Thykof commented Nov 15, 2023

more info here TypeStrong/ts-node#1007

@Thykof
Copy link
Contributor Author

Thykof commented Nov 24, 2023

To fix definitely we can replace ts-node by tsx:

for example in package.json:

    "scripts": {
        "test:e2e": "tsx src/tests/e2e.ts",

or in command line: npx tsc src/tests/e2e.ts

@Ben-Rey Ben-Rey self-assigned this Dec 28, 2023
@Ben-Rey
Copy link
Contributor

Ben-Rey commented Jan 3, 2024

Done in #381

@Ben-Rey Ben-Rey closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants