How to resolve npm 'Missing required argument' error when doing npm install
1. Purpose
In this post, I will demonstrate how to resolve the following error when running npm install
:
root@launch-advisor-20191120:/opt/White-Jotter/wj-vue# npm installnpm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.npm WARN deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-pluginnpm WARN deprecated [email protected]: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-pluginnpm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.npm ERR! Linux 4.15.0-128-genericnpm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"npm ERR! node v8.10.0npm ERR! npm v3.5.2npm ERR! code EMISSINGARG
npm ERR! typeerror Error: Missing required argument #1npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50npm ERR! typeerror This is an error with npm itself. Please report this error at:npm ERR! typeerror <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:npm ERR! /opt/White-Jotter/wj-vue/npm-debug.logroot@launch-advisor-20191120:/opt/White-Jotter/wj-vue#
The core error message is:
npm ERR! Linux 4.15.0-128-genericnpm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"npm ERR! node v8.10.0npm ERR! npm v3.5.2npm ERR! code EMISSINGARG
npm ERR! typeerror Error: Missing required argument #1npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50npm ERR! typeerror This is an error with npm itself. Please report this error at:npm ERR! typeerror <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:npm ERR! /opt/White-Jotter/wj-vue/npm-debug.log
2. The environment
- Ubuntu 18.04.5 LTS
- npm version
root@launch-advisor-20191120:~# npm version{ npm: '3.5.2', ares: '1.14.0', cldr: '32.0.1', http_parser: '2.7.1', icu: '60.2', modules: '57', nghttp2: '1.30.0', node: '8.10.0', openssl: '1.0.2n', tz: '2017c', unicode: '10.0', uv: '1.18.0', v8: '6.2.414.50', zlib: '1.2.11' }root@launch-advisor-20191120:~#
3. The solution
It seems that my npm version is too old, it needs to be upgraded, so I tried this:
root@launch-advisor-20191120:~# npm install -g npm▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟WARN engine [email protected]: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"8.10.0","npm":"3.5.2"})/usr/local/lib└── (empty)
npm ERR! Linux 4.15.0-128-genericnpm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm"npm ERR! node v8.10.0npm ERR! npm v3.5.2npm ERR! path /usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35anpm ERR! code ENOENTnpm ERR! errno -2npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'npm ERR! enoent This is most likely not a problem with npm itselfnpm ERR! enoent and is related to npm not being able to find a file.npm ERR! enoent
npm ERR! Please include the following file with any support request:npm ERR! /root/npm-debug.lognpm ERR! code 1
It’s not working, It seems that the npm and nodejs is integrated by the system, so I decided to remove them from the system:
root@launch-advisor-20191120:~# apt purge npmReading package lists... DoneBuilding dependency treeReading state information... DoneThe following packages were automatically installed and are no longer required: gyp javascript-common libc-ares2 libhttp-parser2.7.1 libjs-async libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libssl1.0-dev libuv1 libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream node-brace-expansion node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight node-inherits node-ini node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-path-is-absolute node-pseudomap node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs nodejs-dev nodejs-docUse 'apt autoremove' to remove them.The following packages will be REMOVED: npm*0 upgraded, 0 newly installed, 1 to remove and 144 not upgraded.After this operation, 10.7 MB disk space will be freed.Do you want to continue? [Y/n] Y(Reading database ... 117180 files and directories currently installed.)Removing npm (3.5.2-0ubuntu4) ...Processing triggers for man-db (2.8.3-2ubuntu0.1) ...root@launch-advisor-20191120:~# apt purge nodeReading package lists... DoneBuilding dependency treeReading state information... DoneE: Unable to locate package noderoot@launch-advisor-20191120:~#
And then install it again:
root@launch-advisor-20191120:~# apt install npm
Then I upgraded npm using the following command:
Node has a module called n
, which is specifically used to manage the version of node.js. Use npm (NPM is a package management tool installed with nodejs) to install the n module:
root@launch-advisor-20191120:~# npm install -g n
Then upgrade the node.js to the latest version:
root@launch-advisor-20191120:~# n stable
Now upgrade the npm again:
root@launch-advisor-20191120:~# npm install npm -g
removed 2 packages, changed 15 packages, and audited 219 packages in 7s
10 packages are looking for funding run `npm fund` for details
3 moderate severity vulnerabilities
To address all issues, run: npm audit fix
Run `npm audit` for details.npm noticenpm notice New patch version of npm available! 8.1.0 -> 8.1.3npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.3npm notice
Now check the npm version:
root@launch-advisor-20191120:~# npm version{ npm: '8.1.3', node: '16.13.0', v8: '9.4.146.19-node.13', uv: '1.42.0', zlib: '1.2.11', brotli: '1.0.9', ares: '1.17.2', modules: '93', nghttp2: '1.45.1', napi: '8', llhttp: '6.0.4', openssl: '1.1.1l+quic', cldr: '39.0', icu: '69.1', tz: '2021a', unicode: '13.0', ngtcp2: '0.1.0-DEV', nghttp3: '0.1.0-DEV'}
Now run npm install again:
root@launch-advisor-20191120:~# npm install
up to date, audited 127 packages in 12s
2 moderate severity vulnerabilities
To address all issues, run: npm audit fix
Run `npm audit` for details.
Now It’s working!
4. Summary
In this post, I demonstrated how to solve the npm upgrade error, you can try as mine. That’s it, thanks for your reading.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!