Skip to content

[RRFC] Add type to npm init #347

@MylesBorins

Description

@MylesBorins

Motivation ("The Why")

The type field is used by many folks to be explicit about the how Node.js interprets the .js extension. It would be great if we could set this field by default, likely to commonjs and give folks the ability to overwrite the default with module (or any other future module type)

Example

{
  "type": commonjs"
}

How

Current Behaviour

Currently this is the default output of npm init --yes

{
  "name": "$FOLDERNAME",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "$USERNAME <$EMAIL>",
  "license": "ISC"
}

Desired Behaviour

{
  "name": "$FOLDERNAME",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "$USERNAME <$EMAIL>",
  "license": "ISC",
  "type": "commonjs"
}

References

https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions