13

I tried to install Node LTS on WSL using NVM. While I successfully installed nvm, Node installation using nvm install --lts made some errors:

mv: cannot move '/home/anesin1109/.nvm/.cache/bin/node-v10.15.3-linux-x64/files/bin' to '/home/anesin1109/.nvm/versions/node/v10.15.3/bin': Permission denied
mv: cannot move '/home/anesin1109/.nvm/.cache/bin/node-v10.15.3-linux-x64/files/include' to '/home/anesin1109/.nvm/versions/node/v10.15.3/include': Permission denied
mv: cannot move '/home/anesin1109/.nvm/.cache/bin/node-v10.15.3-linux-x64/files/lib' to '/home/anesin1109/.nvm/versions/node/v10.15.3/lib': Permission denied
mv: cannot move '/home/anesin1109/.nvm/.cache/bin/node-v10.15.3-linux-x64/files/share' to '/home/anesin1109/.nvm/versions/node/v10.15.3/share': Permission denied

I tried to move these files manually, but it also ended with those errors.

anesin1109
  • 315
  • 3
  • 13

3 Answers3

24

Try making sure nothing is accessing the directory. I had this exact issue. I figured out that my VisualStudio Code had the directory open in the WSL which prevented NVM from doing its thing. After closing VS Code nvm install 12 worked fine. Hope that helps.

Izaak van Dongen
  • 2,450
  • 13
  • 23
KingCruzIII
  • 241
  • 2
  • 4
  • 1
    Closed vscode in my home directory. After that it worked fine! – Gerrit Halfmann Jan 17 '20 at 22:46
  • 1
    Did the same, closed vscode where I was making changes to configs. Thanks. – talves Feb 15 '20 at 00:03
  • 1
    Important detail: Use the native WSL terminal, _not_ the VS code terminal. This bit was not clear to me, but that's what worked. Close VS Code, run `nvm install node` in the Ubuntu terminal, reopen VS Code and happily use Node. – Isaiah Shiner Apr 25 '20 at 13:52
  • 1
    It's such a common pitfall. Lots of us installed WSL, fired up VS Code, and realized npm install doesn't work. Who would have thought to close VS Code before installing nvm? This answer saved my day. Huge thanks! – Chuanqi Sun Jun 18 '20 at 16:37
  • The fact that this is the cause is maddening. When is WSL going to *work*? – Kyeotic Jan 08 '21 at 03:27
3

Please check if your user owns all files in .nvm. You can take ownership recursively with chown -R <user> .nvm. Delete all node versions recursively with rm -rf .nvm/versions/node. Then try again; this process worked for me at least.

0

problem solved with me when i upgrade the WSL distribution from WSL1 to wsl 2

wsl --set-version Ubuntu 2

Ramy Nazmy
  • 11
  • 1
  • 4