Repository: pre-commit/pre-commit
Issue: Executable `prettier` not found

hello hello!

As discussed on discord, I'm having an issue running prettier via pre-commit:

```bash
$ pre-commit --version
pre-commit 2.5.1

$ cat .pre-commit-config.yaml
repos:
  - repo: https://github.com/prettier/prettier
    rev: 2.0.5
    hooks:
      - id: prettier

$ pre-commit clean
Cleaned /home/rkm/.cache/pre-commit.

> pre-commit run prettier --files README.md
[INFO] Initializing environment for https://github.com/prettier/prettier.
[INFO] Installing environment for https://github.com/prettier/prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
prettier.................................................................Failed
- hook id: prettier
- exit code: 1

Executable `prettier` not found
```

it seems like prettier is installed correctly, but the symlink to it is not created:

```bash
$ find ~/.cache/pre-commit/ -name prettier.js
/home/rkm/.cache/pre-commit/repoes79dg4v/bin/prettier.js

$ ls -l $(find ~/.cache/pre-commit/ -name node_env-default)/bin
total 70376
-rwxr-xr-x. 1 rkm rkm     3702 Jun 17 17:30 activate
-rwxr-xr-x. 1 rkm rkm     3964 Jun 17 17:30 activate.fish
-rwxr-xr-x. 1 rkm rkm 72052312 Jun  2 14:33 node
lrwxrwxrwx. 1 rkm rkm        4 Jun 17 17:30 nodejs -> node
lrwxrwxrwx. 1 rkm rkm       38 Jun 17 17:30 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx. 1 rkm rkm       38 Jun 17 17:30 npx -> ../lib/node_modules/npm/bin/npx-cli.js
-rwxr-xr-x. 1 rkm rkm      355 Jun 17 17:30 shim 
```

(doing the same in a docker container results in a `prettier` symlink being created there).

I suspect my VM may be borked somehow, but not sure how to debug this further. Any thoughts? Thanks!


Changed files:
tests/repository_test.py, pre_commit/languages/node.py

diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py
index 26f4919..d99e6f2 100644
--- a/pre_commit/languages/node.py
+++ b/pre_commit/languages/node.py
@@ -10,6 +10,7 @@ import pre_commit.constants as C
 from pre_commit import parse_shebang
 from pre_commit.envcontext import envcontext
 from pre_commit.envcontext import PatchesT
+from pre_commit.envcontext import UNSET
 from pre_commit.envcontext import Var
 from pre_commit.hook import Hook
 from pre_commit.languages import helpers
@@ -56,6 +57,8 @@ def get_env_patch(venv: str) -> PatchesT:
         ('NODE_VIRTUAL_ENV', venv),
         ('NPM_CONFIG_PREFIX', install_prefix),
         ('npm_config_prefix', install_prefix),
+        ('NPM_CONFIG_USERCONFIG', UNSET),
+        ('npm_config_userconfig', UNSET),
         ('NODE_PATH', os.path.join(venv, lib_dir, 'node_modules')),
         ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
     )
diff --git a/tests/repository_test.py b/tests/repository_test.py
index ee57d99..84e4da9 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -260,6 +260,14 @@ def test_run_versioned_node_hook(tempdir_factory, store):
     )
 
 
+@xfailif_windows  # pragma: win32 no cover
+def test_node_hook_with_npm_userconfig_set(tempdir_factory, store, tmpdir):
+    cfg = tmpdir.join('cfg')
+    cfg.write('cache=/dne\\n')
+    with mock.patch.dict(os.environ, NPM_CONFIG_USERCONFIG=str(cfg)):
+        test_run_a_node_hook(tempdir_factory, store)
+
+
 def test_run_a_ruby_hook(tempdir_factory, store):
     _test_hook_repo(
         tempdir_factory, store, 'ruby_hooks_repo',