7

I'm using Windows as a simple user (I don't have any admin rights) and want to install Yarn and use commands like Yarn Install, Yarn Add and Yarn Start.

I found this on Stackoverflow about how to install Node.JS as a local user but I cannot make it work outside that folder: install NodeJS LTS on Windows as a local user (without admin rights)

I now have Node unpacked in the folder: C:\Users\USERNAME\Applications\node and I have added it my path to my variables using: rundll32 sysdm.cpl,EditEnvironmentVariables. I can run node -v and npm -v and it works. I have installed Yarn using npm install --global yarn but I cannot make it work outside of that folder.

I want to go to D:\projects\projectName\app-dev and run Yarn Install to install dependencies from a project I cloned from GitHub. How do I make it work?

UPDATE! For anyone out there the issue was not with Yarn. It was actually with Node.JS and the PATH in environment variable. For whatever reason until I restarted my computer the PATH did not update to include the new location of Node.JS. Make sure you read the answer from this question and you should not have any issues. install NodeJS LTS on Windows as a local user (without admin rights)

tk421
  • 5,775
  • 6
  • 23
  • 34
milotindragos
  • 91
  • 1
  • 1
  • 7

3 Answers3

7

You might be able to install Yarn locally with

  1. npm i -S yarn and then
  2. add it to your path SET PATH=%PATH%;c:\to\your\project\node_modules\.bin\yarn

Now in the same terminal window you can use it with yarn install ...

Highmastdon
  • 6,960
  • 7
  • 40
  • 68
  • Hello @Highmastdon thank you for your reply but the problem was with my Node.JS install without admin rights. The posted answer from here: [link](https://stackoverflow.com/questions/37029089/how-to-install-nodejs-lts-on-windows-as-a-local-user-without-admin-rights) has solved my problem. For whatever reason it did not let me add the new PATH to environment variable. But after an restart it now works. Strange – milotindragos Mar 06 '18 at 18:11
  • Yes this is exactly what I'm mitigating with this way of setting the PATH env-var. – Highmastdon Mar 11 '18 at 23:16
  • 1
    Can you please tell me what this -S flag means in this case? – Konstantink1 Jul 16 '21 at 14:43
  • 1
    @Konstantink1 `npm i --help` says `Options: [-S|--save|...`. So I guess `-S` and `--save` are the same. – Marcus Jun 07 '23 at 19:20
3

Execute npm bin -g which will print the folder name where npm installs executables and add that folder to your path. Restart the command prompt/powershell and it should work.

Strelok
  • 50,229
  • 9
  • 102
  • 115
  • Hello @Strelok thank you for your reply but the problem was with my Node.JS install without admin rights. The posted answer from here: [link](https://stackoverflow.com/questions/37029089/how-to-install-nodejs-lts-on-windows-as-a-local-user-without-admin-rights) has solved my problem. For whatever reason it did not let me add the new PATH to environment variable. But after an restart it now works. Strange – milotindragos Mar 06 '18 at 18:11
0

For anyone out there the issue was not with Yarn. It was actually with Node.JS and the PATH in environment variable.

For whatever reason until I restarted my computer (Windows 10) the PATH did not update to include the new location of Node.JS. Make sure you read the answer from this question and you should not have any issues: install NodeJS LTS on Windows as a local user (without admin rights)

Triple check that node is running and Yarn or any other dependency should work just fine

milotindragos
  • 91
  • 1
  • 1
  • 7