Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

"Module parse failed" #66

Closed
mdreizin opened this issue Oct 28, 2015 · 32 comments
Closed

"Module parse failed" #66

mdreizin opened this issue Oct 28, 2015 · 32 comments

Comments

@mdreizin
Copy link

Using of "preLoaders+loaders" causes "Module parse failed":

module.exports = {
  module: {
    preLoaders: [
      {test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/}
    ],
    loaders: [
      {test: /\.js$/, loader: "babel-loader", exclude: /node_modules/}
    ]
  }
}
ERROR in ./index.js
Module parse failed: ./node_modules/babel-loader/index.js!./node_modules/eslint-loader/index.js!./index.js Line 3: Unexpected token
You may need an appropriate loader to handle this file type.
@nkbt
Copy link
Contributor

nkbt commented Oct 28, 2015

This is strange, I've got exactly same setup and don't have any issues.

Maybe you need babel-eslint in your .eslintrc?

@mdreizin
Copy link
Author

@nkbt I will try to create a repo with example witch causes this error. Let me some time to do it.

@MoOx
Copy link
Contributor

MoOx commented Oct 28, 2015

It seems you just need babel-eslint as a parser for eslint ;)
Reopen if that is not the case, but each time I got this issue, it's just that I use an esNOTEXISTING feature :)

@MoOx MoOx closed this as completed Oct 28, 2015
@iurii-kondratiuk-zz
Copy link

I have the same issue even if I add babel-eslint parser to .eslintrtc:

module.exports = {
  module: {
    preLoaders: [
      {test: /\.js$/, loader: "eslint-loader", exclude: [/node_modules/, /lib/]}
    ],
    loaders: [
      {test: /\.js$/, loader: "babel-loader", exclude: [/node_modules/, /lib/]}
    ]
  }
}
{
  "env": {
    "browser": true,
    "es6": true
  },
  "parser": "babel-eslint"
}

@MoOx
Copy link
Contributor

MoOx commented Nov 4, 2015

What is your input file that trigger an "Unexpected token" issue?
This have probably nothing to do with the fact that you are using eslint as a preloader.
But if you think it is, making a pull request to add a failing test might help us :)

@iurii-kondratiuk-zz
Copy link

It fails on this line and it works fine if I remove the preloader:

import { accountService } from 'services/account.service.js';

And it says:

... Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import { accountService } from 'services/account.service.js';
|
...

@MoOx
Copy link
Contributor

MoOx commented Nov 4, 2015

You don't have this issue if used as a loader before (=> after in the array definition) of babel-loader?

@iurii-kondratiuk-zz
Copy link

I do have it in this case as well.

@MoOx
Copy link
Contributor

MoOx commented Nov 5, 2015

The issue seems related to eslint. Not this loader.
Do you get the same issue via eslint cli?

@mdreizin
Copy link
Author

mdreizin commented Nov 5, 2015

@MoOx I don't get this issue using eslint cli directly.

@iurii-kondratiuk-zz
Copy link

@MoOx I seems that I also don't have it using eslint cli directly.

@gegles
Copy link

gegles commented Nov 5, 2015

I have the exact same issue with all the latest packages installed. Using eslint-loader as a preloader fails!

@mdreizin
Copy link
Author

mdreizin commented Nov 5, 2015

@MoOx please reopen it until it will be fixed.

@gegles
Copy link

gegles commented Nov 5, 2015

Would love to re-open, but I don't have sufficient rights to do so!

Let me know. Thx.

@MoOx
Copy link
Contributor

MoOx commented Nov 5, 2015

Can someone open a PR with a failing test?
I don't have the issue at the moment, maybe it's related to a recent eslint change?

@MoOx MoOx reopened this Nov 5, 2015
@MoOx MoOx changed the title Using of "preLoaders+loaders" causes "Module parse failed" "Module parse failed" Nov 5, 2015
@schickling
Copy link

Having the same problem

@MoOx
Copy link
Contributor

MoOx commented Nov 6, 2015

This module is open source and covered by tests. It is very easy to start working on it: clone the project, the npm install && npm test.

So if you encounter a bug, please take the time to fix it (reminder: Open Source projects work even better with multiples contributors).

If don't want to take the time to fix it because you have others priorities, at least make a pull request with a failing test to expose the bug to the world in order to facilitate things for people that will fix it.

Thanks !

@Halama
Copy link

Halama commented Nov 7, 2015

Hi I have the same issue. I wasn't able to run the tests without errors yet. So I've create the repository which demonstrates the bug https://github.com/Halama/eslint-loader-debug

@MoOx
Copy link
Contributor

MoOx commented Nov 7, 2015

Thanks a lot, that will helps. It's look like it's related to your version of babel.

Can everyone involved here tell which version of babel you are using? babel@6?

(I still use babel@5, that probably why I don't have the issue yet)

@MoOx
Copy link
Contributor

MoOx commented Nov 7, 2015

This might be related babel/babel-eslint#199 / babel/babel-eslint#202 but I am not sure

@iurii-kondratiuk-zz
Copy link

@MoOx I'm using "babel": "^6.0.15"

@schickling
Copy link

    "babel-core": "^6.1.2",
    "babel-eslint": "^4.1.4",
    "babel-loader": "^6.0.1",
    "babel-preset-es2015": "^6.1.2",
    "babel-preset-react": "^6.1.2",
    "babel-runtime": "^6.0.14",

@MoOx
Copy link
Contributor

MoOx commented Nov 7, 2015

So like I said, it looks like it is related to the babel-eslint issue mentioned above (not upgraded to babel 6 yet).

@mdreizin
Copy link
Author

mdreizin commented Nov 7, 2015

I don't use babel@6 and here is my config:

{
    "babel": "^5.8.29",
    "babel-core": "^5.8.30",
    "babel-loader": "^5.3.2",
    "eslint": "^1.7.3",
    "eslint-loader": "^1.1.0",
    "webpack": "^1.12.1"
}

I have the same issue using babel-eslint.

@mdreizin
Copy link
Author

@MoOx Could you please tell us about the progress?

@MoOx
Copy link
Contributor

MoOx commented Nov 18, 2015

I didn't do anything yet because I don't have the issue with all my current project atm.

Also see #66 (comment) if you want to help.

@gegles
Copy link

gegles commented Nov 18, 2015

Everything is now working great for me after upgrading to the latest babel, etc..

Thanks. G.

@Laiff
Copy link

Laiff commented Dec 24, 2015

Problem was in babel-loader, for babel@5 you may use [email protected] it works fine with preLoaders

@MoOx
Copy link
Contributor

MoOx commented Dec 24, 2015

Thanks for reporting this babel issue.

@MoOx MoOx closed this as completed Dec 24, 2015
@pastinepolenta
Copy link

same problem here after migrating to Webpack 2.0 even with babel-loader 6 and 7

ERROR in ./src/index.jsx
Module parse failed: /var/www/images-shelf/node_modules/eslint-loader/index.js!/var/www/images-    shelf/src/index.jsx Unexpected token (18:12)
You may need an appropriate loader to handle this file type.
| render() {
|         return (
|             <h1>
|                 Test
|             </h1>

"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-eslint": "^7.2.2",
"babel-jest": "^18.0.0",
"babel-loader": "^6.4.1",

"eslint": "^3.12.2",
"eslint-config-airbnb": "^13.0.0",
"eslint-loader": "^1.7.1",

rules: [
        {
            enforce: "pre",
            test: /\.jsx?$/,
            loaders: "eslint-loader",
            include: [
                config.paths.src
            ]
        },

@NicolasRannou
Copy link

@stilllife00 did you find out how to fix it?

@NicolasRannou
Copy link

OK my issue was that I was using rules + loaders at the same time. Only using rules fixes it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants