Skip to content

Conversation

@MaxBlack-dev
Copy link
Contributor

Description

This PR updates the scripts.md documentation to remove examples using deprecated and discouraged features.

Changes

  • Examples section: Replaced install/postinstall examples with prepare and est scripts
  • Examples section: Replaced discouraged make commands with modern build tools ( sc, jest)
  • Use Cases section: Changed recommendations from deprecated prepublish to prepare
  • Use Cases section: Updated CoffeeScript example to TypeScript (more current)

Fixes

Closes #3992

Context

The issue reported that the documentation was confusing because it:

  1. Deprecated prepublish but then recommended using it in the Use Cases section
  2. Showed examples using install scripts which are discouraged in the Best Practices section
  3. Used outdated examples (make, uninstall, CoffeeScript)

This update aligns the examples and recommendations with current best practices:

  • Use prepare instead of the deprecated prepublish
  • Avoid install scripts as recommended in Best Practices
  • Use modern tooling that reflects current JavaScript/TypeScript ecosystem

@MaxBlack-dev MaxBlack-dev requested a review from a team as a code owner December 3, 2025 01:57
**Use Cases**

If you need to perform operations on your package before it is used, in a way that is not dependent on the operating system or architecture of the target system, use a `prepublish` script.
If you need to perform operations on your package before it is used, in a way that is not dependent on the operating system or architecture of the target system, use a `prepare` script.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is also very strangely composed. Give a go at rephrasing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've rephrased both sentences:

Line 85: Changed from "If you need to perform operations on your package before it is used, in a way that is not dependent on the operating system or architecture of the target system, use a prepare script" to "Use a prepare script to perform build tasks that are platform-independent and need to run before your package is used."

The new wording is more direct and specific.

* Fetching remote resources that your package will use.

The advantage of doing these things at `prepublish` time is that they can be done once, in a single place, thus reducing complexity and variability.
The advantage of doing these things at `prepare` time is that they can be done once, in a single place, thus reducing complexity and variability.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't add this, but doing these things feels very 3rd grade vague. Mind rewording it while you are here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've rephrased both sentences:

Line 92: Changed from "The advantage of doing these things at prepare time is that they can be done once, in a single place, thus reducing complexity and variability" to "Running these build tasks in the prepare script ensures they happen once, in a single place, reducing complexity and variability."

The new wording is more direct and specific.

…h prepare

- Updated examples section to use prepare and test scripts instead of discouraged install/postinstall
- Changed use case recommendations from prepublish to prepare
- Replaced CoffeeScript example with TypeScript (more current)
- Replaced make commands with modern build tools (tsc, jest)
- Fixes npm#3992
@MaxBlack-dev MaxBlack-dev force-pushed the docs/3992-update-script-examples branch from 0ce48da to 5dcfdbe Compare December 9, 2025 00:23
@MaxBlack-dev
Copy link
Contributor Author

Thanks for the feedback! I've rephrased both sentences:

  1. Line 85: Changed from "If you need to perform operations on your package before it is used, in a way that is not dependent on the operating system or architecture of the target system, use a prepare script" to "Use a prepare script to perform build tasks that are platform-independent and need to run before your package is used."

  2. Line 92: Changed from "The advantage of doing these things at prepare time is that they can be done once, in a single place, thus reducing complexity and variability" to "Running these build tasks in the prepare script ensures they happen once, in a single place, reducing complexity and variability."

The new wording is more direct and specific.

MaxBlack-dev

This comment was marked as duplicate.

@owlstronaut owlstronaut merged commit 7f2ab9d into npm:latest Dec 9, 2025
8 checks passed
@github-actions github-actions bot mentioned this pull request Dec 9, 2025
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.

[BUG] scripts.md promotes the use of deprecated and otherwise discouraged features

2 participants