prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.15k stars 456 forks source link

Extension not working: Cannot find module 'acorn' #858

Closed alexeychikk closed 5 years ago

alexeychikk commented 5 years ago

Extension is not working currently and outputs the following error Cannot find module 'acorn'. Reinstalling didn't help. It helped when I manually installed acorn package in the project's folder even though my project doesn't depend on it.

himanshupnt commented 5 years ago

I'm also facing similar issue. Any plugin in plugins errors out Cannot find module <module name> .eslintrc ->

{
  "parser": "babel-eslint",
  "parserOptions": {
      "sourceType": "module"
  },
  "env": {
    "browser": true,
    "node": true,
    "jest": true,
    "es6": true
  },
  "plugins": [
    "prettier",
    "react",
    "jest"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ],
  "settings": {
    "react": {
      "createClass": "createReactClass",
      "pragma": "React",
      "version": "detect"
    }
  },
  "rules": {
    "react/destructuring-assignment": [2, "always", { "ignoreClassFields": true }],
    "react/no-array-index-key": 2,
    "react/no-unused-state": 2,
    "react/no-unused-prop-types": 2,
    "prettier/prettier": "error",
    "no-nested-ternary": 2,
    "semi": [2, "always"],
    "prefer-destructuring": ["error", {"object": true, "array": true}],
    "prefer-const": ["error", {
      "destructuring": "any"
    }],
    "indent": ["error", 2, { "SwitchCase": 1 }],
    "max-len": ["error", { "code": 120 }]
  }
}

package.json ->

"eslint": "^6.0.0",
    "eslint-config-prettier": "^5.0.0",
    "eslint-plugin-import": "^2.17.3",
    "eslint-plugin-jest": "^22.7.1",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.13.0",
    "prettier": "^1.18.2",
AlaaZorkane commented 5 years ago

Same issue here. VS code throws me an error each time I try to format: image This is only within vscode itself, the cli tool works perfectly using "prettier --write /somefile.js"

Some additional info: eslint debug shows no errors - eslint is working as intended Any plugin/extends throw the same error not only eslint-plugin-prettier Tried installing/uninstalling globally, same issue eveytime.

cannap commented 5 years ago

i donwgraded eslint to ^4.0.0 until a fix

EthanNYT commented 5 years ago

I downgraded eslint to ^4.0.0

Works for me as well:

devias-io commented 5 years ago

Try to remove everything from settings.json. It should fix the problem.

cannap commented 5 years ago

i dont have any prettier related stuff in settings.json

this is my workspace settings.json file

{ "search.exclude": { "/.nuxt": true }, "files.watcherExclude": { "/.nuxt": true }, "files.exclude": { "**/.nuxt": true }, "vue-i18n-ally.localesPaths": "lang" }

samarti commented 5 years ago

What I did was to remove any reference to esLint on settings.json I removed:

{
  "prettier.eslintIntegration": true,
  "eslint.enable": true,
}

and it worked fine

ntotten commented 5 years ago

Duplicate of #870

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.