Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install --no-optional Missing required argument

/usr/bin/npm" "install" "--no-optional giving me following error on ubuntu 16.04

npm ERR! Linux 4.4.0-1098-aws
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-optional"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm 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:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm 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:50
npm 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!     /home/ubuntu/workspace/Master/npm-debug.log

I updated npm with /usr/bin/npm install -g npm@latest but now I get

/usr/local/lib/node_modules/npm/bin/npm-cli.js:85
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

Any idea whats is wrong here ?

like image 275
roy Avatar asked Apr 28 '20 15:04

roy


People also ask

What does npm install without arguments do?

npm install can be run with or without arguments. When run without arguments, npm install downloads dependencies defined in a package. json file and generates a node_modules folder with the installed modules. When run with arguments, npm install downloads specific modules to the node_modules folder.

What is npm install -- ignore scripts?

The option --ignore-scripts disables ALL scripts - even from your dependencies. If your dependencies need to run scripts to e.g. install some binaries they may break / be incomplete.


1 Answers

Your npm version is completely outdated. You are on npm v3.5.2, while npm v6.14.4 has already been released.

You need to upgrade npm to use the --no-optional flag. For that see:

docs.npmjs.com: Try the latest stable version of npm

You can upgrade to the latest version of npm using: npm install -g npm@latest

Edit

How to update node.js

This is a simple solution that works for all supported operating systems including Windows:

After a lot of surfing and not finding a straight solution, I just tried going to Node.js site, clicked the DOWNLOADS button on homepage and executed the installer program (MSI).

Thankfully it took care of everything and with a few clicks of 'Next' button I got the latest Node.js version running on my Windows machine.

(here is the original answer)

Download NodeJS buttons

For Docker users, here's the official Node.js image.


PS: To check your Node version use npm version or node --version.
PPS: Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases.

like image 197
Niklas E. Avatar answered Nov 15 '22 14:11

Niklas E.