2

This is the first time I'm using Volta, so bear with me.

I have installed globally typescript, node and yarn

yarn -v >> 1.22.10
node -v >> v14.15.4
npm -v >> 6.14.10

These commands work inside and outside my project folder, with the same results. However if I use yarn build from inside vscode the output is an error stating: System cannot find the path specified System cannot find the path specified

If I do the same from outside vscode I get the same result: System cannot find the path specified

If I go to the node_modules/.bin folder inside vscode, the command still doesn't work (this time I just only run tsc). The error is the following:

The term tsc is not a cmdlet recognized command, function, script file or executable program. Verify if the name is written correctly or, if there is an access route, verify the route is correct and try again. The term tsc is not a cmdlet recognized command, function, script file or executable program. Verify if the name is written correctly or, if there is an access route, verify the route is correct and try again.

But if the command is executed from outside vscode in a cmd window, it works as expected, because tsc is really there:

tsc is working

Additionally, if I run npm run build inside vscode, the command works as expected. This is my package.json:

{
  "name": "socket-server",
  "version": "1.0.0",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "license": "MIT",
  "scripts": {
    "build": "tsc",
    "dev": "yarn build --watch --preserveWatchOutput",
    "lint": "eslint src --ext js,ts",
    "test": "jest"
  },
  "devDependencies": {
    "eslint": "^7.19.0",
    "jest": "^26.6.3",
    "typescript": "^4.1.3"
  },
  "volta": {
    "node": "14.15.4",
    "yarn": "1.22.10"
  }
}

I do suspect of volta because volta is managing yarn version, but no npm; but I don't really know what's the issue.

I'm using Windows and my PATH has the following entries: Volta and npm paths are present on my user folder

What am I doing wrong?

Edit: Yes, Shell command shortcut exists: Shell command shortcut

David Diez
  • 1,165
  • 1
  • 11
  • 23

2 Answers2

2

the problem is about vsCode, you should run code . in cmd because if you Open the Command Palette (Ctrl + Shift + P) and type

Shell Command: Install 'code' command in PATH

you won't see noting, after running code . in cmd when you should see like this photo, every things will be fine

enter image description here

Mohammad Yaser Ahmadi
  • 4,664
  • 3
  • 17
  • 39
  • Thanks for clearing me some things up, I had to edit the question because it was a bit misleading, I have the issue with `yarn build`, a command that does exists and it seems to be not working inside vscode. It's like because of Volta, vscode doesn't recognize the command `tsc` inside the script (`yarn run build` = `tsc`); but `tsc` does work outside vscode (inside `node_modules\bin`). I really don't know what is exactly causing the issue, I suspect of volta because `npm run build` works perfectly inside vscode, but not with yarn. – David Diez Feb 17 '21 at 06:27
  • w0o0ow the bounty is expired? I answered the question just for bounty +50 – Mohammad Yaser Ahmadi Feb 17 '21 at 10:43
  • I've opened the project via `code .` and made sure I had the shortcut the same as yours. But it seems not related, because the issue is still there – David Diez Feb 17 '21 at 12:29
  • I updated the answer with a picture, the shortcut is there – David Diez Feb 17 '21 at 13:22
  • if you run `volta install node@14` in terminal if vscode, do you see an error again? – Mohammad Yaser Ahmadi Feb 17 '21 at 13:48
  • can you add `C:\Users\David\AppData\Local\Programs\Microsoft VS Code\bin` to the PATH of Environment Variable – Mohammad Yaser Ahmadi Feb 17 '21 at 13:51
  • Added, the issue persists – David Diez Feb 19 '21 at 05:28
1

I’m not sure for Windows, but usually the scripts in node_modules/.bin are symbolic links to scripts. For instance, node_modules/.bin/tsc might point to node_modules/typescript/bin/tsc.

It works outside of the directory because then it uses the global version of tsc.

Seeing your error, I’m suspecting that the symlinks are broken. Maybe just try to remove node_modules directory and redo an npm install.

PS: I’m not familiar with Volta, but it looks more like an NPM problem.

  • I updated the question because it was misleading, the issue is related with `yarn build`, a script command that do exists. Removing `node_modules` unfortunately does not solve the issue – David Diez Feb 17 '21 at 06:21