# Major CLI Versions - Notable Changes (WIP) ## npm v7 #### Timeline: - **Generally Available:** January 2021 - **End-of-Life:** October 2021(?) #### Features: - [x] Install Peer-Depedendencies by Default - [ ] `npm install` throws an error when trying to install a version of itself when there's an `engine` mismatch ## npm v8 #### Timeline: - **Alpha:** August 2021 - **Generally Available:** September 2021 ### Goals - Low friction from `7 -> 8` - Reduce maintenance burden - Align release schedules better with Node Project - Update deps which are dropping support for unsupported nodes ### Breaking Changes - Drop support for `node@10` - Drop programmatic API (ie. no more `require('npm')`) - Re-think the dist-tags we use - THAT'S IT. #### Bikeshedding: - Should we provide a maintenance window for `v7`? ## npm v9 - Early 2022 ### Goals - Standardize reasonable defaults - Support complex workflows ### Features - **Big Change**: refactor `config` layer entirely - unknown config keys or invalid config values will crash the process - use a cli args parser that is simpler and more well-supported than nopt - get rid of side-effecty boolean collections (`--save-dev`, `--save-peer`, etc.) - get rid of nerf-dart and `@scope:registry` cleverness - support registry-specific, scope-specific, and command-specific configs in an organized manner - consider move to json instead of ini (there are many trade-offs here, we should enumerate them and make a decision -- note: "you can nest objects in json" is not a consideration, ini can do this as well) - **Medium Change**: rethink `npm link` - What are the jobs to be done by this command? - How do users _expect_ it to behave in various scenarios? - Given that, design an implementation that meets the user needs optimally. - No commitments at this time to implementation direction. - **Feature**: Differentiate "scripts" from "lifecycle events" - needs RFC - Something like this: ```json { "name": "my-app", "version": "1.0.0", "events": { "install": "npm run build" }, "scripts": { "build": "node build.js" } } ``` - `"events"` defaults to running the appropriate thing from `scripts` for backwards compatibility (possibly with a deprecation notice?) - if `"events"` contains an unknown key, we crash - `"events"` may not be executed explicitly via `run-script`, only scripts can be. - `"events"` value may be an array of script names to run? ```json { "events": { "preinstall": ["build:css", "build:js", "build:html"] }, "scripts": { "build:css": "etc", ... } } ``` - **Remove** `npm set-script` - New command: `npm add` - @isaacs: this is just "npm install but fails if no positional args", correct? - New command: `npm adduser` (alias, `register`) - New command: `npm workspace` (alias, `ws`) - `npm ws add ./foo` === `npm init -w foo` + `cd foo/ && echo "workspace-root=../" > .npmrc` - `npm ws remove ./foo` === `rm -rf ./foo` - `npm update` supports saving back to `package.json` via `--save` - `npm doctor` refactor - Workspace & Run Script Concurrance - `--concurrently` flag introduced to `npm run` & `-w` or `-ws` - Workspace alias' - `npm ws alias <name> <path>` - Workspace & Run Script Groups - `npm run build` - `npm run build -ws internal` - Reevaluate package-init default bin entry behavior ```json= { "scripts": { "build:css": "...", "build:js": "...", "build:html": "..." }, "workspace": { "internal:tools": "./internal/tools", "internal:server": "./internal/server" } } ``` ##### `package.json` ```json= { "name": "pkg", "version": "1.0.0", "npm": { "commands": { "install": { "save": true } } } } ``` - New Context Config Mappings - `--local` maps to `--location=local` - `--user` maps to `--location=user` - `--remote` maps to `--location=remote` - `--global` maps to `--location=global` - Auth w/ GitHub (ready when it is) - New Exec Commands - `npm exec [list|add|remove]` ### Notable Breaking Changes - `npm add` is no longer an alias to `npm install` - `npm adduser` is no longer an alias to `npm login` - `npm login` is no longer an alias to `npm adduser` - `--local` no longer maps to `--no-global` - `npm config` defaults to modify the `local` `--location` by default - `auth-type` removed - `node-gyp` update to latest ## npm v10 - uses `strict` mode by default - New `npm link` experience