prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Use of --dev deprecated for npm
  I'm seeing this warning sometimes (output seems to be hidden unless the install fails):
  
  ```
  npm WARN install Usage of the `--dev` option is deprecated. Use `--include=dev` instead.
  ```
  
  Which seems to be because of this:
  
  https://github.com/pre-commit/pre-commit/blob/fe436f1eb09dfdd67032b4f9f8dfa543fb99cf06/pre_commit/languages/node.py#L104
  
  The problem with this command was that it installed dependencies recursively, rendering them useless (AFAICT, not a node expert). The developers decided it was only a footgun in https://github.com/npm/npm/issues/5554#issuecomment-56121953 and deprecated in https://github.com/npm/npm/issues/6200.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pre_commit/languages/node.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import contextlib
  4 import functools
  5 import os
  6 import sys
  7 from typing import Generator
  8 from typing import Sequence
  9 
  10 import pre_commit.constants as C
  11 from pre_commit import lang_base
  12 from pre_commit.envcontext import envcontext
  13 from pre_commit.envcontext import PatchesT
  14 from pre_commit.envcontext import UNSET
  15 from pre_commit.envcontext import Var
  16 from pre_commit.languages.python import bin_dir
  17 from pre_commit.prefix import Prefix
  18 from pre_commit.util import cmd_output
  19 from pre_commit.util import cmd_output_b
  20 from pre_commit.util import rmtree
  21 
  22 ENVIRONMENT_DIR = 'node_env'
  23 run_hook = lang_base.basic_run_hook
  24 
  25 
  26 @functools.lru_cache(maxsize=1)
  27 def get_default_version() -> str:
  28     # nodeenv does not yet support `-n system` on windows
  29     if sys.platform == 'win32':
  30         return C.DEFAULT
  31     # if node is already installed, we can save a bunch of setup time by
  32     # using the installed version
  33     elif all(lang_base.exe_exists(exe) for exe in ('node', 'npm')):
  34         return 'system'
  35     else:
  36         return C.DEFAULT
  37 
  38 
  39 def get_env_patch(venv: str) -> PatchesT:
  40     if sys.platform == 'cygwin':  # pragma: no cover
  41         _, win_venv, _ = cmd_output('cygpath', '-w', venv)
  42         install_prefix = fr'{win_venv.strip()}\bin'
  43         lib_dir = 'lib'
  44     elif sys.platform == 'win32':  # pragma: no cover
  45         install_prefix = bin_dir(venv)
  46         lib_dir = 'Scripts'
  47     else:  # pragma: win32 no cover
  48         install_prefix = venv
  49         lib_dir = 'lib'
  50     return (
  51         ('NODE_VIRTUAL_ENV', venv),
  52         ('NPM_CONFIG_PREFIX', install_prefix),
  53         ('npm_config_prefix', install_prefix),
  54         ('NPM_CONFIG_USERCONFIG', UNSET),
  55         ('npm_config_userconfig', UNSET),
  56         ('NODE_PATH', os.path.join(venv, lib_dir, 'node_modules')),
  57         ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
  58     )
  59 
  60 
  61 @contextlib.contextmanager
  62 def in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:
  63     envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
  64     with envcontext(get_env_patch(envdir)):
  65         yield
  66 
  67 
  68 def health_check(prefix: Prefix, version: str) -> str | None:
  69     with in_env(prefix, version):
  70         retcode, _, _ = cmd_output_b('node', '--version', check=False)
  71         if retcode != 0:  # pragma: win32 no cover
  72             return f'`node --version` returned {retcode}'
  73         else:
  74             return None
  75 
  76 
  77 def install_environment(
  78         prefix: Prefix, version: str, additional_dependencies: Sequence[str],
  79 ) -> None:
  80     assert prefix.exists('package.json')
  81     envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
  82 
  83     # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath
  84     if sys.platform == 'win32':  # pragma: no cover
  85         envdir = fr'\\?\{os.path.normpath(envdir)}'
  86     cmd = [sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir]
  87     if version != C.DEFAULT:
  88         cmd.extend(['-n', version])
  89     cmd_output_b(*cmd)
  90 
  91     with in_env(prefix, version):
  92         # https://npm.community/t/npm-install-g-git-vs-git-clone-cd-npm-install-g/5449
  93         # install as if we installed from git
  94 
  95         local_install_cmd = (
  96             'npm', 'install', '--dev', '--prod',
  97             '--ignore-prepublish', '--no-progress', '--no-save',
  98         )
  99         lang_base.setup_cmd(prefix, local_install_cmd)
  100 
  101         _, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir)
  102         pkg = prefix.path(pkg.strip())
  103 
  104         install = ('npm', 'install', '-g', pkg, *additional_dependencies)
  105         lang_base.setup_cmd(prefix, install)
  106 
  107         # clean these up after installation
  108         if prefix.exists('node_modules'):  # pragma: win32 no cover
  109             rmtree(prefix.path('node_modules'))
  110         os.remove(pkg)
  111
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py
  --- a/pre_commit/languages/node.py
  +++ b/pre_commit/languages/node.py
  @@ -93,7 +93,7 @@
           # install as if we installed from git
   
           local_install_cmd = (
  -            'npm', 'install', '--dev', '--prod',
  +            'npm', 'install', '--include=dev', '--include=prod',
               '--ignore-prepublish', '--no-progress', '--no-save',
           )
           lang_base.setup_cmd(prefix, local_install_cmd)
  
verification_info: {"golden_diff": "diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py\n--- a/pre_commit/languages/node.py\n+++ b/pre_commit/languages/node.py\n@@ -93,7 +93,7 @@\n         # install as if we installed from git\n \n         local_install_cmd = (\n-            'npm', 'install', '--dev', '--prod',\n+            'npm', 'install', '--include=dev', '--include=prod',\n             '--ignore-prepublish', '--no-progress', '--no-save',\n         )\n         lang_base.setup_cmd(prefix, local_install_cmd)\n", "issue": "Use of --dev deprecated for npm\nI'm seeing this warning sometimes (output seems to be hidden unless the install fails):\r\n\r\n```\r\nnpm WARN install Usage of the `--dev` option is deprecated. Use `--include=dev` instead.\r\n```\r\n\r\nWhich seems to be because of this:\r\n\r\nhttps://github.com/pre-commit/pre-commit/blob/fe436f1eb09dfdd67032b4f9f8dfa543fb99cf06/pre_commit/languages/node.py#L104\r\n\r\nThe problem with this command was that it installed dependencies recursively, rendering them useless (AFAICT, not a node expert). The developers decided it was only a footgun in https://github.com/npm/npm/issues/5554#issuecomment-56121953 and deprecated in https://github.com/npm/npm/issues/6200.\n", "before_files": [{"content": "from __future__ import annotations\n\nimport contextlib\nimport functools\nimport os\nimport sys\nfrom typing import Generator\nfrom typing import Sequence\n\nimport pre_commit.constants as C\nfrom pre_commit import lang_base\nfrom pre_commit.envcontext import envcontext\nfrom pre_commit.envcontext import PatchesT\nfrom pre_commit.envcontext import UNSET\nfrom pre_commit.envcontext import Var\nfrom pre_commit.languages.python import bin_dir\nfrom pre_commit.prefix import Prefix\nfrom pre_commit.util import cmd_output\nfrom pre_commit.util import cmd_output_b\nfrom pre_commit.util import rmtree\n\nENVIRONMENT_DIR = 'node_env'\nrun_hook = lang_base.basic_run_hook\n\n\n@functools.lru_cache(maxsize=1)\ndef get_default_version() -> str:\n    # nodeenv does not yet support `-n system` on windows\n    if sys.platform == 'win32':\n        return C.DEFAULT\n    # if node is already installed, we can save a bunch of setup time by\n    # using the installed version\n    elif all(lang_base.exe_exists(exe) for exe in ('node', 'npm')):\n        return 'system'\n    else:\n        return C.DEFAULT\n\n\ndef get_env_patch(venv: str) -> PatchesT:\n    if sys.platform == 'cygwin':  # pragma: no cover\n        _, win_venv, _ = cmd_output('cygpath', '-w', venv)\n        install_prefix = fr'{win_venv.strip()}\\bin'\n        lib_dir = 'lib'\n    elif sys.platform == 'win32':  # pragma: no cover\n        install_prefix = bin_dir(venv)\n        lib_dir = 'Scripts'\n    else:  # pragma: win32 no cover\n        install_prefix = venv\n        lib_dir = 'lib'\n    return (\n        ('NODE_VIRTUAL_ENV', venv),\n        ('NPM_CONFIG_PREFIX', install_prefix),\n        ('npm_config_prefix', install_prefix),\n        ('NPM_CONFIG_USERCONFIG', UNSET),\n        ('npm_config_userconfig', UNSET),\n        ('NODE_PATH', os.path.join(venv, lib_dir, 'node_modules')),\n        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),\n    )\n\n\n@contextlib.contextmanager\ndef in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:\n    envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)\n    with envcontext(get_env_patch(envdir)):\n        yield\n\n\ndef health_check(prefix: Prefix, version: str) -> str | None:\n    with in_env(prefix, version):\n        retcode, _, _ = cmd_output_b('node', '--version', check=False)\n        if retcode != 0:  # pragma: win32 no cover\n            return f'`node --version` returned {retcode}'\n        else:\n            return None\n\n\ndef install_environment(\n        prefix: Prefix, version: str, additional_dependencies: Sequence[str],\n) -> None:\n    assert prefix.exists('package.json')\n    envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)\n\n    # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath\n    if sys.platform == 'win32':  # pragma: no cover\n        envdir = fr'\\\\?\\{os.path.normpath(envdir)}'\n    cmd = [sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir]\n    if version != C.DEFAULT:\n        cmd.extend(['-n', version])\n    cmd_output_b(*cmd)\n\n    with in_env(prefix, version):\n        # https://npm.community/t/npm-install-g-git-vs-git-clone-cd-npm-install-g/5449\n        # install as if we installed from git\n\n        local_install_cmd = (\n            'npm', 'install', '--dev', '--prod',\n            '--ignore-prepublish', '--no-progress', '--no-save',\n        )\n        lang_base.setup_cmd(prefix, local_install_cmd)\n\n        _, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir)\n        pkg = prefix.path(pkg.strip())\n\n        install = ('npm', 'install', '-g', pkg, *additional_dependencies)\n        lang_base.setup_cmd(prefix, install)\n\n        # clean these up after installation\n        if prefix.exists('node_modules'):  # pragma: win32 no cover\n            rmtree(prefix.path('node_modules'))\n        os.remove(pkg)\n", "path": "pre_commit/languages/node.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport contextlib\nimport functools\nimport os\nimport sys\nfrom typing import Generator\nfrom typing import Sequence\n\nimport pre_commit.constants as C\nfrom pre_commit import lang_base\nfrom pre_commit.envcontext import envcontext\nfrom pre_commit.envcontext import PatchesT\nfrom pre_commit.envcontext import UNSET\nfrom pre_commit.envcontext import Var\nfrom pre_commit.languages.python import bin_dir\nfrom pre_commit.prefix import Prefix\nfrom pre_commit.util import cmd_output\nfrom pre_commit.util import cmd_output_b\nfrom pre_commit.util import rmtree\n\nENVIRONMENT_DIR = 'node_env'\nrun_hook = lang_base.basic_run_hook\n\n\n@functools.lru_cache(maxsize=1)\ndef get_default_version() -> str:\n    # nodeenv does not yet support `-n system` on windows\n    if sys.platform == 'win32':\n        return C.DEFAULT\n    # if node is already installed, we can save a bunch of setup time by\n    # using the installed version\n    elif all(lang_base.exe_exists(exe) for exe in ('node', 'npm')):\n        return 'system'\n    else:\n        return C.DEFAULT\n\n\ndef get_env_patch(venv: str) -> PatchesT:\n    if sys.platform == 'cygwin':  # pragma: no cover\n        _, win_venv, _ = cmd_output('cygpath', '-w', venv)\n        install_prefix = fr'{win_venv.strip()}\\bin'\n        lib_dir = 'lib'\n    elif sys.platform == 'win32':  # pragma: no cover\n        install_prefix = bin_dir(venv)\n        lib_dir = 'Scripts'\n    else:  # pragma: win32 no cover\n        install_prefix = venv\n        lib_dir = 'lib'\n    return (\n        ('NODE_VIRTUAL_ENV', venv),\n        ('NPM_CONFIG_PREFIX', install_prefix),\n        ('npm_config_prefix', install_prefix),\n        ('NPM_CONFIG_USERCONFIG', UNSET),\n        ('npm_config_userconfig', UNSET),\n        ('NODE_PATH', os.path.join(venv, lib_dir, 'node_modules')),\n        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),\n    )\n\n\n@contextlib.contextmanager\ndef in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:\n    envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)\n    with envcontext(get_env_patch(envdir)):\n        yield\n\n\ndef health_check(prefix: Prefix, version: str) -> str | None:\n    with in_env(prefix, version):\n        retcode, _, _ = cmd_output_b('node', '--version', check=False)\n        if retcode != 0:  # pragma: win32 no cover\n            return f'`node --version` returned {retcode}'\n        else:\n            return None\n\n\ndef install_environment(\n        prefix: Prefix, version: str, additional_dependencies: Sequence[str],\n) -> None:\n    assert prefix.exists('package.json')\n    envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)\n\n    # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath\n    if sys.platform == 'win32':  # pragma: no cover\n        envdir = fr'\\\\?\\{os.path.normpath(envdir)}'\n    cmd = [sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir]\n    if version != C.DEFAULT:\n        cmd.extend(['-n', version])\n    cmd_output_b(*cmd)\n\n    with in_env(prefix, version):\n        # https://npm.community/t/npm-install-g-git-vs-git-clone-cd-npm-install-g/5449\n        # install as if we installed from git\n\n        local_install_cmd = (\n            'npm', 'install', '--include=dev', '--include=prod',\n            '--ignore-prepublish', '--no-progress', '--no-save',\n        )\n        lang_base.setup_cmd(prefix, local_install_cmd)\n\n        _, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir)\n        pkg = prefix.path(pkg.strip())\n\n        install = ('npm', 'install', '-g', pkg, *additional_dependencies)\n        lang_base.setup_cmd(prefix, install)\n\n        # clean these up after installation\n        if prefix.exists('node_modules'):  # pragma: win32 no cover\n            rmtree(prefix.path('node_modules'))\n        os.remove(pkg)\n", "path": "pre_commit/languages/node.py"}]}