Tom*_*Tom 14 node.js npm eslint package.json prettier
我更新了所有软件包,但在运行npm run serve后仍然出现此错误:
模块构建失败(来自 ./node_modules/eslint-loader/index.js):错误:无法找到模块 'prettier' 在 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)
Run Code Online (Sandbox Code Playgroud)
我多次尝试删除package-lock.json和node_modules并在之后运行 npm install 。没有什么可以修复它 - 甚至全局更新所有软件包。
Ste*_*ado 35
Prettier是@vue/eslint-config-prettier 的一个对等依赖, 所以你需要把它添加到你自己的依赖中:
npm install --save-dev prettier
Run Code Online (Sandbox Code Playgroud)
小智 12
如果您使用的是yarn 3,并且yarn add --dev prettier
不能解决您的问题,请尝试以下操作:
cmd
+ shift
+p
preferences: open user settings (json)
"prettier.prettierPath": ".yarn/sdks/prettier/index.js"
到您的 json 文件。这告诉您的编辑器在您添加的路径中找到该模块。
注意:如果没有sdks
目录,.yarn
请确保第一次运行以下命令来生成相关目录。
Yarn 4.0.0-rc.48
yarn dlx @yarnpkg/sdks base
Run Code Online (Sandbox Code Playgroud)
您可以在文档中阅读有关编辑器 sdks 的更多信息
与NPM
npm install --save-dev prettier
Run Code Online (Sandbox Code Playgroud)
有纱
yarn add --dev prettier
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23651 次 |
最近记录: |