npm install eslint 缺少参数错误

ash*_*noy 8 node.js npm eslint npm-install

我正在尝试在项目文件夹中本地安装 eslint。但是,如https://eslint.org 上所述进行安装

npm install eslint --save-dev
Run Code Online (Sandbox Code Playgroud)

返回以下错误:

npm ERR! Linux 4.15.0-70-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "eslint" "--save-dev"
npm ERR! node v8.10.0
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/ashish/Documents/Web-Development/Bootcamp/auth-test/npm-debug.log
Run Code Online (Sandbox Code Playgroud)

我试过全局安装 eslint,也没有将依赖项保存到 package.json 但出现相同的错误消息。

npm 不会为任何其他包(快递、请求等)返回错误。这似乎只发生在 eslint 上。

Mic*_* B. 12

你的 npm 版本太旧(4 年了),需要更新

npm i -g npm
Run Code Online (Sandbox Code Playgroud)

还要考虑更新node,版本 8End-of-life自 2019 年 12 月 31 日起。https ://github.com/nodejs/Release


小智 11

我已经尝试过上述方法,但不幸的是,它对我不起作用。另一种方式可能是这样的:

  1. 将 nodejs 更新到最新版本:

    sudo npm install -g n
    sudo n latest
    
    Run Code Online (Sandbox Code Playgroud)
  2. 将 npm 更新到最新版本:

    sudo npm install -g npm
    
    Run Code Online (Sandbox Code Playgroud)
  3. 做@runcible 建议的事情:

    hash -d npm
    
    Run Code Online (Sandbox Code Playgroud)
  4. 试试 npm 安装:

    npm i
    
    Run Code Online (Sandbox Code Playgroud)