gpt4 book ai didi

node.js - npm install --no-optional缺少必需的参数

转载 作者:行者123 更新时间:2023-12-03 12:11:00 27 4
gpt4 key购买 nike

/usr/bin/npm" "install" "--no-optional在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

我用 npm更新了 /usr/bin/npm install -g npm@latest,但现在我得到了
/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

知道这里有什么问题吗?

最佳答案

您的npm版本已完全过时。您正在使用npm v3.5.2,而npm v6.14.4已发布。

您需要升级npm才能使用--no-optional标志。为此,请参见:

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



编辑

如何更新node.js

这是一个简单的解决方案,适用于所有受支持的操作系统,包括 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.



(这是 original answer)

Download NodeJS buttons

对于 Docker用户,这是官方的 Node.js image

PS:要检查您的Node版本,请使用 npm versionnode --version
PPS:密切关注 NodeJS blog - Vulnerabilities,这样您就不会错过重要的安全发布。

关于node.js - npm install --no-optional缺少必需的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61484377/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com