0

I am trying to yarn start with git bash "start": "node scripts/start.js",
It always works when using PowerShell or CMD.
But it does not work with git bash.

But when I tried to node scripts/start.js instead yarn start with bash it works!

I tested git bash
yarn -v, node -v, npm -v, every command works well.

But not work with scripts...

This is the error message

'node' is not recognized as an internal or external command

And i tried to "startStart": "yarn start",
And this time bash gives me this error message

'yarn ' is not recognized as an internal or external command

I checked my env PATH but all is fine.

--- ENV VS_CODE
OS : window 10
node : 13.5
npm : 6.13.4

I installed git-bash with git
And all install config is default-standard


Add

I think Git-Bash can find the path when it is alone
I think we should focus on that it can't find path only when it try to trigger package.json scripts

About .profile I didn't know what it is and I never created it.
If it is not default - exist I don't have it.

Community
  • 1
  • 1
MINJA KIM
  • 876
  • 1
  • 8
  • 22
  • 1
    when you run `echo $PATH` do you see `` – madhu sudhan Dec 30 '19 at 11:48
  • If you `cd` to your project directory and run the following command via git bash: `npm run env | grep ^PATH=` and similarly using [`yarn-run-env`](https://yarnpkg.com/lang/en/docs/cli/run/#toc-yarn-run-env) command, i.e. `yarn run env | grep ^PATH=` - what do they it return ? – RobC Dec 30 '19 at 12:40
  • Could you please do let us know if you imported your DOT profile in your script? – RavinderSingh13 Dec 30 '19 at 13:45
  • @madhu sudhan yes i can see like this ```...:/c/Program Files/nodejs:/cmd:/c/Users/colto....``` – MINJA KIM Dec 30 '19 at 14:12
  • Does `ls -l /c/Program Files/nodejs/node` show that the x-bit is set? – user1934428 Dec 30 '19 at 14:14
  • 1
    @RobC i can see paths..... ```PATH=/c/Program Files/nodejs/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/c/Users/colto/Desktop/projects/jd-booking-client/node_modules/.bin:/mingw64/bin:/usr/bin:/c/Users/colto/bin:/c/Program Files (x86)/NAT Service:/c/ProgramData/Boxstarter:/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compi...``` – MINJA KIM Dec 30 '19 at 14:17
  • @RavinderSingh13 I just knew that what is .profile and i never created it. i tried to figure out file is exist or not ... it dose not exist i think - – MINJA KIM Dec 30 '19 at 14:19
  • @user1934428 I do not know what you mean but ... ```/c/Program Files/nodejs``` in here i try to command ```ls -l``` and i got ```total 28143 -rw-r--r-- 1 colto 197610 2953 Dec 16 17:03 install_tools.bat -rwxr-xr-x 1 colto 197610 28787352 Dec 17 06:55 node.exe -rw-r--r-- 1 colto 197610 8997 Oct 10 06:01 node_etw_provider.man drwxr-xr-x 1 colto 197610 0 Dec 30 18:08 node_modules -rw-r--r-- 1 colto 197610 702 Oct 10 06:01 nodevars.bat -rwxr-xr-x 1 colto 197610 930 Dec 13 06:01 npm -rw-r--r-- 1 colto 197610 483 Oct 10 06:01 npm.cmd``` – MINJA KIM Dec 30 '19 at 14:29
  • If you invoke _node_ by its full path, `"/c/Program Files/nodejs/node.exe"` (don't forget the quotes), does it work then? – user1934428 Dec 31 '19 at 14:48

1 Answers1

4

without to relate to windows specific, npm executes scripts commands (specified in package.json) under the default shell, but it does not perform a login to the shell.

for instance, a bash login (bash --login) in order to use your custom system environment variable.

you can change this by using .npmrc file and set the script-shell. see this answer for the solution.

i hope this is what you suffer from :)

Mr.
  • 9,429
  • 13
  • 58
  • 82