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

feat: remove npm bin #5459

Merged
merged 1 commit into from
Sep 8, 2022
Merged

feat: remove npm bin #5459

merged 1 commit into from
Sep 8, 2022

Conversation

wraithgar
Copy link
Member

@wraithgar wraithgar commented Sep 1, 2022

BREAKING CHANGE: this removes the npm bin command

The output of this command is misleading and incomplete. The .bin
resolution of npm is much more nuanced than this command implies, and
the output of npm bin is not something end users should be dealing
with. npm itself is responsible for running the bin entries of
modules, with the exception of global bins, which end up in the same
folder as node itself, presumably already in a user's path since they
can run node.

Closes npm/statusboard#537

@wraithgar wraithgar requested a review from a team as a code owner September 1, 2022 17:24
BREAKING CHANGE: this removes the `npm bin` command

The output of this command is misleading and incomplete.  The `.bin`
resolution of npm is much more nuanced than this command implies, and
the output of `npm bin` is not somthing end users should be dealing
with.  `npm` itself is responsible for running the `bin` entries of
modules, with the exception of global bins, which end up in the same
folder as `node` itself, presumably already in a user's path since they
can run node.

Closes npm/statusboard#537
@npm-cli-bot
Copy link
Collaborator

npm-cli-bot commented Sep 1, 2022

no statistically significant performance changes detected

timing results
app-large clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 40.795 ±0.18 15.664 ±0.34 13.913 ±0.00 17.452 ±2.58 2.503 ±0.01 2.485 ±0.01 2.057 ±0.01 9.583 ±0.03 2.062 ±0.01 3.009 ±0.01
#5459 39.849 ±4.39 15.656 ±0.07 14.085 ±0.11 16.871 ±1.09 2.580 ±0.02 2.522 ±0.01 2.075 ±0.01 9.758 ±0.07 2.099 ±0.01 3.284 ±0.27
app-medium clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 27.548 ±1.93 11.924 ±0.01 10.605 ±0.02 11.509 ±0.06 2.338 ±0.02 2.366 ±0.04 2.096 ±0.01 7.231 ±0.12 2.006 ±0.01 2.735 ±0.04
#5459 28.273 ±0.62 12.147 ±0.16 10.660 ±0.01 11.528 ±0.10 2.333 ±0.01 2.321 ±0.01 2.138 ±0.02 7.213 ±0.15 2.021 ±0.06 2.842 ±0.19

@wraithgar wraithgar marked this pull request as draft September 8, 2022 16:21
@wraithgar
Copy link
Member Author

flipped to draft while we discuss this

@wraithgar wraithgar marked this pull request as ready for review September 8, 2022 16:37
@wraithgar wraithgar merged commit 2e92800 into latest Sep 8, 2022
@wraithgar wraithgar deleted the gar/remove-bin branch September 8, 2022 16:50
haines added a commit to cerbos/cerbos-sdk-javascript that referenced this pull request Nov 10, 2022
`npm bin` was removed: npm/cli#5459

Signed-off-by: Andrew Haines <haines@cerbos.dev>
haines added a commit to cerbos/cerbos-sdk-javascript that referenced this pull request Nov 10, 2022
`npm bin` was removed: npm/cli#5459

Signed-off-by: Andrew Haines <haines@cerbos.dev>
haines added a commit to cerbos/cerbos-sdk-javascript that referenced this pull request Nov 10, 2022
* chore(deps): update npm to v9
* Run jest using `npm exec`
  `npm bin` was removed: npm/cli#5459

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Signed-off-by: Andrew Haines <haines@cerbos.dev>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Andrew Haines <haines@cerbos.dev>
dch90 pushed a commit to aws-solutions/media-insights-on-aws that referenced this pull request Feb 8, 2023
Background
==========

The build script used `npm bin` to fetch the local bin path for running
`cdk` commands.

See https://docs.npmjs.com/cli/v8/commands/npm-bin

npm version 9 removed the `bin` command so it no longer works.

See npm/cli#5459

Change
======

Changed the way the script gets the npm execution environment.

Added some clean-up to the script to remove the CloudFormation template
staging directory.

Updated the "Copy Dist to S3" guard code so it does not try to copy to
any of the reference buckets.
colinazn added a commit to aws-solutions/media-insights-on-aws that referenced this pull request Feb 14, 2023
Background
==========

The build script used `npm bin` to fetch the local bin path for running
`cdk` commands.

See https://docs.npmjs.com/cli/v8/commands/npm-bin

npm version 9 removed the `bin` command so it no longer works.

See npm/cli#5459

Change
======

Changed the way the script gets the npm execution environment.

Added some clean-up to the script to remove the CloudFormation template
staging directory.

Updated the "Copy Dist to S3" guard code so it does not try to copy to
any of the reference buckets.
douglasnaphas added a commit to douglasnaphas/aws-cdk that referenced this pull request Jun 9, 2023
`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.
douglasnaphas added a commit to douglasnaphas/aws-cdk that referenced this pull request Jun 9, 2023
`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.
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Jun 12, 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/cli#5459). `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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BREAKING CHANGE(bin): remove command
3 participants