Fill these in once
- Make a folder for global packages and tell npm to use it
mkdir -p ~/.npm-global npm config set prefix ~/.npm-globalNever fix this with sudo npm. Using nvm avoids the problem completely.
- Add that folder to your PATH
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc source ~/.zshrc - Install again, without sudo
npm install -g typescript
Check it worked
- Check where global packages go now
npm config get prefix
Undo it
- Go back to npm's default folder
npm config delete prefix
- Make a folder for global packages and tell npm to use it
mkdir -p ~/.npm-global npm config set prefix ~/.npm-globalNever fix this with sudo npm. Using nvm avoids the problem completely.
- Add that folder to your PATH
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc source ~/.bashrc - Install again, without sudo
npm install -g typescript
Check it worked
- Check where global packages go now
npm config get prefix
Undo it
- Go back to npm's default folder
npm config delete prefix
This error is a macOS and Linux problem. On Windows, npm's EPERM error usually means another program has the folder open: close VS Code and other terminals, then try again.