Babel-eslint: Cannot find module babel-eslint using eslint command line.

Created on 7 Apr 2016  路  2Comments  路  Source: babel/babel-eslint

We have a centralized styleguide across the organization. In my repository we have this in dependencies

    "@org/styleguide": "0.0.7",

Which is a private repository in npmjs. We have been using gulp for a while and we decided to go pure npm This is our gulp config which is working fine.

      5 gulp.task('lint', function performLint() {
      6   return gulp
      7     .src(['./**/*.js', '!node_modules/**/*.js'])
      8     .pipe(eslint({
      9       'configFile': '.eslintrc',
     10       'fix': true
     11      }))
     12     .pipe(eslint.format())
     13     .pipe(eslint.failOnError());
     14 });

This is my .eslintrc

      1 {
      2   "parser": "babel-eslint",
      3   "extends": "./node_modules/@org/styleguide/.eslintrc",
      4   "env": {
      5     "node": true,
      6     "mocha": true
      7   },
      8   "rules": {
      9     "strict": [0, "global"],
     10     "global-strict": [0, "always"],
     11     "new-cap": [2, {"capIsNew":false}],
     12     "func-style": [2, "expression", { "allowArrowFunctions": true }]
     13   }
     14 }

We have inherited from the styleguide project. If I use gulp to run lint it's working correctly. However, when I run eslint . in the terminal I get this error.

  0:0  error  Cannot find module 'babel-eslint'

I tried installing babel-eslint manually but it didn't solve the problem.

This is package.json of @org/styleguide/package.json which has babel-lint.

     13   "devDependencies": {},
     14   "peerDependencies": {
     15     "eslint-plugin-react": "~3.3.0",
     16     "babel-eslint": "~4.1.0"
     17   },

I'm not sure how to debug this.

We're using Node 4.2.2 and npm 2.14.7

Most helpful comment

It's because when you run eslint . it's probably running the global eslint rather than the local one? ./node_modules/.bin/eslint . or use an npm script

All 2 comments

Try this setting:

You don't need to add babel-eslint as a dependency. Just check this setting in Atom.

It's because when you run eslint . it's probably running the global eslint rather than the local one? ./node_modules/.bin/eslint . or use an npm script

Was this page helpful?
0 / 5 - 0 ratings