Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove npm bin from scripts #25913

Merged
merged 3 commits into from
Jun 12, 2023
Merged

chore: Remove npm bin from scripts #25913

merged 3 commits into from
Jun 12, 2023

Conversation

douglasnaphas
Copy link
Contributor

@douglasnaphas douglasnaphas commented Jun 9, 2023

This change removes the expression export PATH=$(npm bin):$PATH, which had formerly been used in scripts to ensure node_modules is in PATH.

npm bin was removed in npm 9. npm exec or npx should be used instead. build.sh already uses npx. This change revises scripts/gen.sh to use npx as well.

Prior to this change, within shells executing build.sh or scripts/gen.sh, PATH actually contains error text if npm 9+ is used.

~/repos/aws-cdk $ docker run --rm -v $PWD:$PWD -w $PWD node:hydrogen-alpine sh -c 'node --version && npm --version && export PATH=$(npm bin):$PATH && echo $PATH' # output when npm bin is unavailable
v18.16.0
9.5.1
Unknown command: "bin" To see a list of supported npm commands, run: npm help:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

~/repos/aws-cdk $ docker run --rm -v $PWD:$PWD -w $PWD node:gallium-alpine sh -c 'node --version && npm --version && export PATH=$(npm bin):$PATH && echo $PATH' # output when npm bin is available
v16.20.0
8.19.4
/Users/douglasnaphas/repos/aws-cdk/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

It didn't make build.sh fail, because lerna has been run via npx since #24217, and build.sh doesn't need anything from node_modules to be added to PATH. export PATH=$(npm bin):$PATH succeeds even though npm bin fails, per export's normal behavior.

Prior to this change, scripts/gen.sh failed with

./scripts/gen.sh: line 18: lerna: command not found

when I ran it. After this change, scripts/gen.sh ran successfully.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

`npm bin` was [removed in npm 9](npm/cli#5459).
`npx` or `npm exec` should be used instead. `build.sh` already uses `npm
exec`, since aws#24217.
`npm bin` was [removed in npm 9](npm/cli#5459).
`npx` or `npm exec` should be used instead. [This
comment](aws#24217 (comment))
on a similar PR, and the discussion on the [PR in npm removing `npm
bin`](npm/cli#5459) explain why `npx lerna` is
preferable.
@gitpod-io
Copy link

gitpod-io bot commented Jun 9, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team June 9, 2023 02:17
@github-actions github-actions bot added p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Jun 9, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 9, 2023
@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 415dc20
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 12fe60e into aws:main Jun 12, 2023
@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants