I am trying to run on desktop this repository a vscode extension.
I cloned it locally and run npm install
Press f5 on vscode editor and got an error
Process exited with code 1
(node:1404) 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)
internal/process/warning:44
Canceled
To work around with the warning I found another stackoverflow question - (node:9374) Warning: To load an ES module, set "type": "module"
So I set "type":"module"
on package.json
and press f5 again.
and another error show up.
Process exited with code 1
Uncaught TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /mnt/c/vscode-php-debug/src/phpDebug.ts
And found another question on stackoverflow - Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts
So I remove "type":"module" what happens is I'm in the loop now, confuse.
Does anyone tried debugging this or encounter as such?
Using the following command worked for me with node v14.16.1:
node --loader ts-node/esm --experimental-specifier-resolution=node index.ts
There is a warning telling me that --experimental-loader
is an experimental feature but I don't care because I only use it to debug the typescript code.
setting "type": "module"
in your package.json
should work. Check again if you made an error in inputting it. Solved my problem when I inputted it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With