Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pre_commit/languages/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,8 @@ def install_environment(
cmd_output_b(*cmd)

with in_env(prefix, version):
install = ('npm', 'install', '--allow-git=root', '-g', *pkgs)
install = (
'npm', 'install', '--allow-git=root', '--install-links', '-g',
*pkgs,
)
lang_base.setup_cmd(prefix, install)
15 changes: 15 additions & 0 deletions tests/languages/node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ def test_node_hook_versions(tmp_path, version):
assert ret == (0, b'Hello World\n')


def test_npm_install_succeeds_with_build(tmp_path):
_make_hello_world(tmp_path)

with open(tmp_path.joinpath('package.json')) as f:
contents = json.load(f)
contents['scripts'] = {'build': 'echo hello hello'}
with open(tmp_path.joinpath('package.json'), 'w') as f:
json.dump(contents, f)
_make_repo(tmp_path)

# node version chosen to be npm 11.19.0 with this particular bug
ret = run_language(tmp_path, node, 'node-hello', version='26.7.0')
assert ret == (0, b'Hello World\n')


def test_node_additional_deps(tmp_path):
_make_local_repo(str(tmp_path))
ret, out = run_language(tmp_path, node, 'npm ls -g', deps=('lodash',))
Expand Down
Loading