nodejs / nodejs/userland-migrations

Changing the value of `process.config`

Open
#408 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue human help wanted let's do it
Dominant language
TypeScript
Stars
85
Forks
55
Avg merge
3d 11h
Merged PRs (30d)
9

Description

Description

Since changing the value of process.config is deprecated (DEP0150) and has reached End-of-Life status in Node.js v19.0.0, we should provide a codemod to address it.

  • The codemod should identify attempts to modify process.config.
  • The codemod should remove or comment out assignments to process.config properties.
  • The codemod should add comments explaining that process.config is now immutable.
  • The codemod should preserve read-only access to process.config.

Additional Information

Note that in Node.js v19.0.0, process.config has been made immutable. The property provides access to Node.js compile-time settings, but it was previously mutable and therefore subject to tampering. This could lead to unexpected behavior and security issues.

Developers can still read from process.config, but any attempts to modify its values will now throw an error. If you need to store configuration, use a separate configuration object or module instead.

Examples

Example 1: Direct assignment to process.config

Before:

process.config.target_defaults = { cflags: [] };

After:

// process.config is now immutable and cannot be modified
// Store custom configuration in a separate object instead
const customConfig = { target_defaults: { cflags: [] } };
Example 2: Modifying nested property

Before:

process.config.variables.node_prefix = "/custom/path";

After:

// process.config is now immutable and cannot be modified
// Use a separate configuration object for custom values
const myConfig = { variables: { node_prefix: "/custom/path" } };
Example 3: Adding new property

Before:

process.config.custom = "value";

After:

// process.config is now immutable and cannot be modified
// Create a separate configuration object
const appConfig = { custom: "value" };
Example 4: Reading process.config (valid, no change needed)

Before:

const nodeVersion = process.config.variables.node_version;
console.log("Node version:", nodeVersion);

After:

const nodeVersion = process.config.variables.node_version;
console.log("Node version:", nodeVersion);
Example 5: Conditional modification

Before:

if (someCondition) {
  process.config.variables.debug = true;
}

After:

// process.config is now immutable and cannot be modified
// Use a separate debug configuration object
const debugConfig = {};
if (someCondition) {
  debugConfig.debug = true;
}
Example 6: Using Object.assign

Before:

Object.assign(process.config, { custom: "settings" });

After:

// process.config is now immutable and cannot be modified
// Create a new configuration object that includes process.config values
const config = Object.assign({}, process.config, { custom: "settings" });
Example 7: Deleting property

Before:

delete process.config.variables.some_property;

After:

// process.config is now immutable - properties cannot be deleted
// If you need a modified copy, create a new object
const config = { ...process.config };
delete config.variables.some_property;
Example 8: Spread operator with modifications

Before:

const config = { ...process.config };
process.config.updated = true;

After:

// process.config is now immutable and cannot be modified
// Work with the copied object instead
const config = { ...process.config };
config.updated = true;

Refs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named in the issue. Start by locating the repository's codemod entry point and existing transformation tests, then cover the listed assignment, nested mutation, Object.assign, delete, and spread cases while leaving reads unchanged. Done means attempted process.config mutations are removed or commented with guidance and the examples are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.