From 21314969a165f6b24b7b7ee1532bc627d5759962 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Mon, 22 Jun 2026 10:08:23 -0700 Subject: [PATCH] fix: clarify Connect uses npm in Node.js lockfile error The "No package-lock.json found" error raised when deploying Node.js content now states that Connect installs Node.js dependencies with npm, so publishers who build with yarn or pnpm understand why the lock file is required. Part of posit-dev/connect#40767 Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/CHANGELOG.md | 3 +++ rsconnect/environment_node.py | 1 + tests/test_environment_node.py | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4f2b3cee..0d7c2a9e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- The "no package-lock.json" error when deploying Node.js content now states + that Connect installs Node.js dependencies with npm, helping publishers who + build with yarn or pnpm understand why a `package-lock.json` is required. - `pyproject.toml` can now be supplied via `--requirements-file` for deploy and write-manifest. - Perform case insensitive matching of the configured Snowflake connection authenticator. diff --git a/rsconnect/environment_node.py b/rsconnect/environment_node.py index 30ff0183..9e962a42 100644 --- a/rsconnect/environment_node.py +++ b/rsconnect/environment_node.py @@ -75,6 +75,7 @@ def create( if not has_lock_file: raise RSConnectException( f"No package-lock.json found in '{directory}'. " + "Connect installs Node.js dependencies with npm. " "Both package.json and package-lock.json are required to deploy Node.js content." ) diff --git a/tests/test_environment_node.py b/tests/test_environment_node.py index 6a866234..cbbec72b 100644 --- a/tests/test_environment_node.py +++ b/tests/test_environment_node.py @@ -42,7 +42,10 @@ def test_create_basic(self, mock_run): def test_create_no_lock_file(self, mock_run, tmp_path): (tmp_path / "package.json").write_text(json.dumps({"dependencies": {"express": "^4.21.0"}})) (tmp_path / "app.js").write_text("// app") - with pytest.raises(RSConnectException, match="No package-lock.json found"): + with pytest.raises( + RSConnectException, + match="No package-lock.json found.*Connect installs Node.js dependencies with npm", + ): NodeEnvironment.create(str(tmp_path)) @patch("rsconnect.environment_node.subprocess.run", side_effect=_mock_run)