Vscode-code-runner: /bin/sh: ts-node: command not found

Created on 18 Aug 2017  路  9Comments  路  Source: formulahendry/vscode-code-runner

I have already install ts-node.

I did not do any setting up.

question wontfix

Most helpful comment

You need either put ts-node in your PATH environment variable, or set the path of ts-node in File->Preference->Settings:

"code-runner.executorMap": {
    "typescript": "node_modules/.bin/ts-node"
}

All 9 comments

Is ts-node in your PATH environment variable, and have you restarted VS Code?

@formulahendry ts-node in node_modules/.bin/ts-node. And, I use command + q quit vscode and restarted. The problem still there

You need either put ts-node in your PATH environment variable, or set the path of ts-node in File->Preference->Settings:

"code-runner.executorMap": {
    "typescript": "node_modules/.bin/ts-node"
}

@formulahendry

  1. I don't want to use ts-node installed globally.
  2. expect code-runner look up ts-node locally, if local ts-node is not existed, then look up global one.

Since Code Runner supports several languages and user is able to customize the path, we will not support this feature. You could udpate executorMap per your need.

is it possible for code runner supports the use of npx which automatically loads the binaries from local node_modules, and bundles it with the locally installed ts-node automatically so that we don't need to add anything to the user setting/ workspace setting?

@HaoyangFan I am not familiar with npx. It is loaded in .bashrc? If it is, you could run the code in terminal which will load .bashrc: "code-runner.runInTerminal": true

My solution is:

 "code-runner.executorMap": {
    "typescript": "node -r ts-node/register",
    "javascript": "node"
  }

I think it's better than the solution @formulahendry provided. You don't need care about the path like this: ${whatever PATH}/node_modules/.bin/ts-node. Because the PATH often changes.

you must install ts-node global, u can try again

Was this page helpful?
0 / 5 - 0 ratings