美文网首页
npm ERR! Refusing to install pac

npm ERR! Refusing to install pac

作者: 顽皮的雪狐七七 | 来源:发表于2020-11-04 15:32 被阅读0次

    目录

    • 出错现象
    • 出错原因
    • 解决方案

    出错现象

    npm init -y初始化之后,安装项目npm i prettier -D报错

    PS E:\professer\StyleLint\Prettier> npm i prettier -D       
    npm ERR! code ENOSELF
    npm ERR! Refusing to install package with name "prettier" under a package
    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!     C:\Users\AppData\Roaming\npm-cache\_logs\2020-11-02T13_49_21_069Z-debug.log
    

    出错原因

    两次都出现这个错误,其实和prettier包没有关系,是因为package.json的项目名称和安装的依赖同名导致

    {
      "name": "prettier",
      "version": "0.1.0",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "license": "MIT",
      "devDependencies": {},
      "keywords": []
    }
    
    

    解决方案

    修改package.json中的nameprettier-sample,总之不要和安装的包名相同即可。

    相关文章

      网友评论

          本文标题:npm ERR! Refusing to install pac

          本文链接:https://www.haomeiwen.com/subject/vmdbvktx.html