Volta with yarn run build system cannot find the path specified

Viewed 1713

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

2 Answers

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

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.

Related