-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React - Module parse failed: You may need an appropriate loader to handle this file type. #173
Comments
I should add that if I run:
from the command line, it parses correctly, which led me to believe it was an issue with babel-loader and/or webpack. |
i am having a similar issue with web pack and babel |
@westdavidr Your resolve and module properties are incorrectly enclosed in the output property. Try this:
|
@stevenross You are correct. I'm not sure if I should bang my head harder for such a simple mistake, or thank you for the answer. Haha. Thanks! |
This should help for those who're still looking for solution: My webpack.config.js file with working hot reloading
|
Hi I am start learning react and i am facing similar type of issue. |
web.config.js file module.exports = { import React from 'react'; Contact list) } } error in console : |
Hey @varunkot
|
I am also facing same issue today. webpack.config.jsmodule.exports = {
entry: "./public/main.js",
output: {
path: __dirname + "/public",
filename: "/bundle.js"
},
module: {
loader: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets : ['es2015', 'react']
}
}]
},
watch: true
} main.jsimport React from 'react';
import ReactDOM from 'react-dom';
import App from './App.jsx';
ReactDOM.render(<App />, document.getElementById('app')); App.jsimport React from 'react';
class App extends React.Component {
render() {
return (
<div>
<h2>Content</h2>
<p>The content text!!!</p>
</div>
);
}
}
export default App; index.ejs within views folder<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Express React Redux</title>
<link rel="stylesheet" href="../css/mystyles.css">
</head>
<body>
<h1>Index Page</h1>
<div id="app">
</div>
<script type="text/javascript" src="../bundle.js">
</body>
</html> Error Windowpackage.json{
"name": "express_react_redux",
"version": "1.0.0",
"description": "simple react redux expressjs app",
"main": "index.js",
"scripts": {
"webpack": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"ejs": "^2.5.5",
"express": "^4.14.0",
"pug": "^2.0.0-beta7",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"webpack": "^1.14.0"
}
} |
In |
I have the same problem
here is my package.json file
My main.js file
i get the following error
|
@stalakokkula Your |
Hi, @stalakokkula, I got the same error and still not sure about the reason. I'm on node v7.7.2
My index.jsx
My webpack-config.js
|
Your |
Oh!
|
If you post a repository that reproduces the issue we can take a look, but nothing jumps out at me that would be wrong. |
I had same issue today while I was experimenting with Redux tutorial from its site. I was using my custom directory structure.
my index file was in
and that file was referring components so I got error message that I need appropriate loader then I've moved my components and containers folders into /src folder and everything begin to work okay for me. P.S: I was using create-react-app |
I am just starting out with react and have been facing similar issue ERROR in ./dev/index.jsx Hello, {this.props.greetTarget}! | ); | } package.json: { web pack.config.js: var webpack = require("webpack"); var DEV = path.resolve(__dirname, "dev"); var config = { module.exports = config; where is the issue here? |
Hi again! I'm using node v7.8.0 and npm 4.2.0 This is what I get (now on webpack 2.3.2 same error): Thanks in advance. |
@pbarrientos I might be wrong, but I think the problem is not with webpack nor babel-loader, but with babel itself due to the way babel does lookup behaviour. See this for more information https://babeljs.io/docs/usage/babelrc/#lookup-behavior I could be wrong though. |
It seems you are right, @Couto Thank you all. |
I am facing the same issue, here's my webpack.config.js
Here's my babelrc:
This is the error that I'm getting:
./node_modules/.bin/webpack -d ERROR in ./app/javascripts/app1.jsx |
The error is line 5 column 11, what is your code on that line? |
This is the line:
|
And your |
@ujjwalvaish Alright, I'd recommend you join our support channel on https://slack.babeljs.io/ so we can chat. There's too much noise on this issue as it is. |
Although this issue is closed, it is easily found via google, so adding my solution in case it helps. For me babel was configured in Updating to e.g.
Solved my problem. This may apply to you even if your babel options are configured elsewhere. |
I'm stuck on this same error and I need fresh eyes for help.... I'm confused on the "appropriate loader" ERROR in ./src/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src This is my src/index.js
webpack.dev.config.js
.babelrc
and my package.json
|
@MadRiver44 i met the same problem,have you solved it,please? webpack.config
.babelrc
packge.json
index.js
|
@ciloi I temporarily solved this by rolling back to an earlier version of webpack dev server. I put my project down for a few days and I am now getting back to it. As of now I reworking my webpack, react setup to the latest version, webpack 4.8 and dev-server 3.11. The problem seems to be resolved but now I have a .scss loader issue. Look at my repo, webpack starter kit to compare. |
@ MadRiver44thanks anyway |
webpack.config.js
|
Thanks to my mate @seanchambo 🙇 we finally fixed a similar issue that we were facing with the same error message. It turns out that it is related to the project path. The issue occurs when we put the project in a path like this:
And the issue disappears when the project path is a simpler one like this:
|
For those that still have this issue and want a temporary workaround, remove css imports from from any js file and move it to a sass file |
In my case, this happens when using Lerna & Yarn workspaces with multiple CRA Apps. |
Firstly make sure it picks the right config file: "build": "./node_modules/.bin/webpack --mode production --config ./webpack/webpack.config.js". Then make sure you use the right presets in .babelrc Then make sure you have the right loader: This is for webpack version: "webpack": "^4.29.6", |
I got this error when I listed my presets in the babelrc file and the webpack config. Once I commented them out of the webpack config, the error was gone. |
Can somebody spot anything I am doing wrong here 🙈 |
My mistake was I didn't add the babel plugin that transforms So for
For
Hope that helps someone! |
I am also facing the same problem, But I am not getting solution for this.I guess here I have seen people helping and guiding. Please help. I am trying to use this react diff library (https://github.com/praneshr/react-diff-viewer) in my react project -. Got added, while building and using I am getting this error- ERROR in ./compliance/app/compliance/~/react-diff-viewer/lib/styles.js .babelrc file -> In my babel i have "babel-preset-react", "babel-preset-stage-0" and "es2015" please check.
package.json file ->
I got to know that I have to use Webpack loader to make it work. Could you please help me with this ? Thanks. Asked the query in stack overflow as well -> |
Hi there, I'm also facing similar problems to OP but the solutions listed here didn't help me either. The errors look like the below:
webpack.config.js:
package.json
|
Solutions listed here didn't help. I did the following and it worked.
Doing npm run build produces the following: -->
The files are here. |
In case this might help, i'll admit him a noob just getting into React. Anyway, checked and rechecked everything, couldn't find one problem, the only strange thing i did was change my to , mainly as i'm working through each rev of the code the instructor wipes, wanted what i worked on for reference later. Was working fine for the last few hours then bingo "Loader to handle not found..." For me the fix was easy, i closed everything and simply did: npm run build So question what if you only do "npm start", had tried that a number of time then thought lets build it... No more errors :) That was all that was needed and got me past the "No appropriate loader"... Just in case my versions: |
I've been banging my head against the wall all day trying to figure this one out.
Here's my relevant package.json:
and web pack.config.js:
and then running webpack from the command line.
Am I missing something obvious here?
The text was updated successfully, but these errors were encountered: