【问题标题】:Can't install ESLint in project folder - npm error code ENOSELF无法在项目文件夹中安装 ESLint - npm 错误代码 ENOSELF
【发布时间】:2020-04-25 02:06:11
【问题描述】:

我正在努力从我的终端(本地在我的项目文件夹中)安装 ESLint。 我正在运行这个命令: sudo npm install eslint --save-dev 但是,返回带有代码 ENOSELF 的 npm 错误,并带有以下消息

npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "eslint" under a package
npm ERR! also called "eslint". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/[username]/.npm/_logs/2020-01-07T14_32_27_111Z-debug.log

我没有名为 eslint 的文件夹或文件或任何远程接近的文件。在我的项目目录中,我有一组用 VSCode 编辑过的 html、js 和 csv 文件。

我真的很困惑为什么会发生这个错误,希望能得到帮助。

【问题讨论】:

    标签: npm terminal npm-install eslint eslintrc


    【解决方案1】:

    确保package.json 中的name 属性不是eslint

    【讨论】:

    • 我没有一个 json 文件,所以创建了一个,它似乎有所帮助......现在当我尝试运行 eslint [filename] 时,我收到错误 -bash: /usr/local /bin/eslint: 没有这样的文件或目录
    • 因为eslint安装在node_modules。您可以使用 npx eslint./node_modules/.bin/eslint 运行它,或者全局安装 eslint npm install eslint -g 以从任何目录运行它
    • 谢谢,已经解决了——抱歉有点慢,我对 nodeJS 还很陌生!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-20
    • 2021-12-15
    • 2021-11-06
    相关资源
    最近更新 更多