Ci, completion and config cli options
In this tutorial we will examine the workings of the ci, completion and config cli options of npm.
The npm-ci command is used to install a project with a clean slate.
Ensure that you have a package-lock and an install that is up to date:
$ cd ./my/npm/project $ npm install added 202 packages in 10s $ ls | grep package-lock
Then, npm ci inside that project
`$ npm ci
added 201 packages in 5s
you should configure Travis to use npm ci to build instead of npm install:
# .travis.yml install: - npm ci # keep the npm cache around so as to speed up installs cache: directories: - "$HOME/.npm"
The npm-ci command is similar to npm install, the only difference is that it is meant to be used in an automated environment such as test platforms, continuous integration, and deployment. The command can be significantly faster than a regular npm install by skipping certain user-oriented features. It is equally stricter than a regular install, this helps catch errors or inconsistencies that results from incrementally-installed local environment of most npm users.
Here are the main differences between using npm install and npm ci:
- The project should have an existing package-lock.json or npm-shrinkwrap.json.
- If dependencies in the package lock don't match those in package.json, npm ci exits with an error, rather than updating the package lock.
- npm ci will only be able to install entire projects at a time: individual dependencies will not be added with this command.
- In the case where a node_modules is already present, it is automatically removed before npm ci begins its install.
- Npm ci will never write to package.json or any of your package-locks: all installs are essentially frozen.
The npm-completion is a tab completion for npm.
source <(npm completion)
The npm-completion enables tab-completion in all npm commands.
The synopsis given above, will load the completions into your current shell. Adding it to your ~/.bashrc or ~/.zshrc makes the completions available everywhere:
npm completion >> ~/.bashrc npm completion >> ~/.zshrc
it is also possible to pipe the output of npm completion to a file such as /usr/local/etc/bash_completion.d/npm if you have a system that reads that file for you.
When COMP_CWORD, COMP_LINE, and COMP_POINT are defined in the environment, npm completion will act in "plumbing mode" and will output completions based on the arguments.
The npm-config is used to manage the npm configuration files.
npm config set
[-g|--global] npm config get <key> npm config delete <key> npm config list [-l] [--json] npm config edit npm get <key> npm set <key> <value> [-g|--global] aliases: c
The config setting for npm is gotten from the command line, environment variables, npmrc files, and in some cases, the package.json file.
You can use the npm config command to update and edit the contents of the user and the global npmrc files.
The npm-config supports the following sub-commands:
This sub-command sets the config key to the value.
npm config set key value
If you omit this value, then it is set to true by default.
npm config get key
The get sub-command will echo the config value to stdout.
npm config list
Shows all the config settings. You should use -l to also allow show defaults. Using the -json flag will show the setting in json format.
npm config delete key
This command will delete the keys from all configuration files.
npm config edit
This sub-command will open the coding file in an editor. You should use the -global flag to edit the global config.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join