This is an article written for specifying on how to update npm which is well-known as a Javascript Package Manager. Furthermore, it is actually a tool that can be considered as a tool specialized on dependency module required upon building on a web-based application.
Actually the event for updating npm utility triggered upon executing a command for installing a package called ‘jquery’ by typing the following command :
npm -i jquery
The above command executed in the following output :
user@hostname:/var/www/html/laravel$ npm -i jquery Usage: npm <command> where <command> is one of: access, adduser, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, dist-tag, docs, doctor, edit, explore, get, help, help-search, i, init, install, install-test, it, link, list, ln, login, logout, ls, outdated, owner, pack, ping, prefix, prune, publish, rb, rebuild, repo, restart, root, run, run-script, s, se, search, set, shrinkwrap, star, stars, start, stop, t, team, test, tst, un, uninstall, unpublish, unstar, up, update, v, version, view, whoami npm <command> -h quick help on <command> npm -l display full usage info npm help <term> search for help on <term> npm help npm involved overview Specify configs in the ini-formatted file: /home/user/.npmrc or on the command line via: npm <command> --key value Config info can be viewed via: npm help config [email protected] /usr/local/lib/node_modules/npm ╭─────────────────────────────────────╮ │ │ │Update available 5.4.2 → 5.5.1 │ │Run npm i -g npm to update │ │ │ ╰─────────────────────────────────────╯ user@hostname:/var/www/html/laravel$
The command is actually a false one since the output of the command is hinting the correct way for executing npm to install a module which in this context is JQuery. After the information given that an update is available, it has been decided to update the npm utility first before executing further operation.
Try to update the npm tool by executing the following command with the output generated :
user@hostname:/var/www/html/laravel$ npm i -g npm npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/abbrev npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/aproba npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/npm-packlist npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/aws-sign2 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/ajv npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/har-schema npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/node_modules/hoek npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/node_modules/boom npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/node_modules/cryptiles npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/node_modules/sntp npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/assert-plus npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/assert-plus npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/extsprintf npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/verror npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/assert-plus npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/mime-types/node_modules/mime-db npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/mime-types npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/form-data npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/performance-now npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/qs npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/rimraf npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/meant npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/npm-registry-client npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/request/node_modules/mime-types/node_modules npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm ERR! path /usr/local/lib/node_modules/npm/node_modules/abbrev npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/abbrev' npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/abbrev' npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/abbrev\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules/npm/node_modules/abbrev' } npm ERR! npm ERR! Please try running this command again as root/Administrator. ╭─────────────────────────────────────╮ │ │ │ Update available 5.4.2 → 5.5.1 │ │ Run npm i -g npm to update │ │ │ ╰─────────────────────────────────────╯ npm ERR! A complete log of this run can be found in: npm ERR! /home/user/.npm/_logs/2017-10-31T04_22_09_034Z-debug.log user@hostname:/var/www/html/laravel$
Based on the output above, the update process cannot be done using a normal user account. The update process need to be done in root account. So, as shown in the output below using root account try to update npm module :
root@hostname:/var/www/html/laravel# npm i -g npm /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js + [email protected] added 52 packages, removed 2 packages and updated 29 packages in 18.042s root@hostname:/var/www/html/laravel#
As shown in the above output, the process for updating npm has already finished.
As for the previous failure command, to install module itself can be done by executing the following command :
npm install jquery
One thought on “How to Update npm via Command Line in Linux Operating System”