npm install eslint 缺少参数错误

npm install eslint missing argument error

我正在尝试在本地项目文件夹中安装 eslint。但是按照 https://eslint.org

中提到的安装
npm install eslint --save-dev

returns 出现以下错误:

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

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

npm 不会 return 任何其他包(express、request 等)的错误。这似乎只发生在 eslint 上。

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

npm i -g npm

同时考虑更新 node,版本 8 自 2019 年 12 月 31 日起 End-of-lifehttps://github.com/nodejs/Release

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

  1. 更新nodejs到最新版本:

    sudo npm install -g n
    sudo n latest
    
  2. 将 npm 更新到最新版本:

    sudo npm install -g npm
    
  3. 执行@runcible 建议的操作:

    hash -d npm
    
  4. 尝试 npm 安装:

    npm i
    

对我来说,上面建议的解决方案无法安装更新版本的节点。我用卷曲做到了。这里是目前为止最新的 15.x 节点

sudo apt install nodejs

curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -

sudo apt install nodejs