node.js - 找不到模块 'prettier'

标签 node.js npm eslint package.json prettier

我更新了所有软件包,但运行后仍然出现此错误 npm 运行服务 :

Module build failed (from ./node_modules/eslint-loader/index.js): Error: Cannot find module 'prettier' Occurred while linting /home



我的 package.json
{
  "name": "app",
  "version": "0.1.0",
  "private": false,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.2.1",
    "firebase": "^7.0.0",
    "material-icons": "^0.3.1",
    "register-service-worker": "^1.6.2",
    "vue": "^2.6.10",
    "vue-flickity": "^1.2.1",
    "vue-router": "^3.1.3",
    "vuetify": "^2.0.19",
    "vuex": "^3.1.1"
  },
  "devDependencies": {
    "@mdi/font": "^4.4.95",
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-eslint": "^3.11.0",
    "@vue/cli-plugin-pwa": "^3.11.0",
    "@vue/cli-service": "^3.11.0",
    "@vue/eslint-config-prettier": "^5.0.0",
    "babel-eslint": "^10.0.3",
    "eslint": "^6.4.0",
    "eslint-plugin-vue": "^5.2.3",
    "material-design-icons-iconfont": "^5.0.1",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "vue-cli-plugin-vuetify": "^0.6.3",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.3.0",
    "webpack": "^4.41.0",
    "webpack-cli": "^3.3.9"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/prettier"
    ],
    "rules": {
      "no-console": "off"
    },
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

**"@vue/eslint-config-prettier": "^5.0.0",** is listed in the dependencies. How to fix this issue? (I'm using VSCODE on Ubuntu)

我尝试多次删除包锁.json Node 模块 然后运行 ​​npm install 。没有什么可以解决它 - 甚至在全局范围内更新所有软件包。

最佳答案

更漂亮是对等依赖
@vue/eslint-config-prettier 所以你需要将它添加到你自己的依赖项中:

npm install --save-dev prettier

关于node.js - 找不到模块 'prettier',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58145870/

相关文章:

javascript - 检查 Typescript 中的默认值

eslint - 是否有 ESLint 规则在分配上对齐 `=`

javascript - 如何将我的正则表达式检测 127.0.0.1/8 IP 转换为更安全的 IP?

node.js - 使用 npm-check-updates 更新时未找到 Package.json 错误

angular - ng-pick-datetime 日期选择器格式

node.js - 尝试安装 body-parser 时出错

javascript - 简单的 Node.JS REST API 调用

javascript - "Uncaught SyntaxError: import declarations may only appear at top level of a module":1:18 asking again

c++ - native v8::Promise 结果

javascript - 使用AJAX调用Node.js文件发送短信