Answer the question
In order to leave comments, you need to log in
REACT. Does Babel compile the old version of the file?
Hello, I've searched all over the Internet and haven't found a working solution to the problem.
I'm picking react on django, everything was fine until I managed to leave myself a comment in Cyrillic right in the code of the react component. Well, so that when he came and it was immediately clear where he stopped.
When he came to continue, he launched the front, back, everything seems to be normal.
I go to localhost and the components are not rendered. I look in the chrome console and see:
Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\ music_controller\frontend\src\components\createroompage.js: Unexpected token, expected ";" (43:20)
[0m [90m 41 | [39m }[0m
[0m [90m 42 | [39m[0m
[0m[31m[1m>[22m[39m[90m 43 | [39m [33mSTOP[39m [33mON[39m [33mVOLUME[39m [33mWHAT[39m [33mGET[39m [33mBAD[39m [33mREQUEST[39m [33mON[39m [33mMY[39m [33mKEY[39m [33m-[39m [33mVALUE[ 39m[0m
[0m[90m | [39m [31m[1m^[22m[39m[0m
[0m [90m 44 | [39m[0m
[0m[90m 45 | [39m fetch([32m'api/crapiview'[39m[33m,[39m requestOptions)[33m;[39m[0m
[0m [90m 46 | [39m }[0m
at Object._raise (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:748:17)
at Object.raiseWithData (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:741:17)
at Object.raise (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:735:17)
at Object.unexpected (C :\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:9097:16)
at Object.semicolon (C:\Users\Lenovo B590 \Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:9079:40)
at Object.parseExpressionStatement (C:\Users\Lenovo B590\Documents\DEV\React -DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:12190:10)
at Object.parseStatementContent (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller \frontend\node_modules\@babel\parser\lib\index.js:11786:19)
at Object.parseStatement (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:11650:17)
at Object.parseBlockOrModuleBlockBody (C :\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:12232:25)
at Object.parseBlockBody (C:\Users\Lenovo B590 \Documents\DEV\React-DDJ.TWT\music_controller\frontend\node_modules\@babel\parser\lib\index.js:12218:10)
at eval ( webpack://frontend/./src/components/createroompage.. . )
at Object../src/components/createroompage.js ( 127.0.0.1:8000/static/frontend/main.js:2:4127 )
at __webpack_require__ (127.0.0.1:8000/static/frontend/main.js:2:251468 )
at eval ( webpack://frontend/./src/components/homepage.js?:6:73 )
at Object../src/components /homepage.js ( 127.0.0.1:8000/static/frontend/main.js:2:7470 )
at __webpack_require__ ( 127.0.0.1:8000/static/frontend/main.js:2:251468 )
at eval ( webpack:/ /frontend/./src/components/app.js?:6:67 )
at Object../src/components/app.js ( 127.0.0.1:8000/static/frontend/main.js:2:2509 )
at __webpack_require__ ( 127.0.0.1:8000/static/frontend/main.js:2:251468 )
at eval ( webpack://frontend/./src/index.js?:2:76)
Among the krakozyabrs, the Cyrillic alphabet is visible, it is clear that the matter is in it and the error is because of it. I go to the file and delete my comments, save the changes, refresh, and everything is the same there. I went down to reboot the computer, and nothing has changed either.
Judging by the error path Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): I sin on babel-loader.
Like I didn't change the file (C:\Users\Lenovo B590\Documents\DEV\React-DDJ.TWT\music_controller\frontend\src\components\createroompage.js) and even left the file where it sees the error as empty, it's all it still writes the same error where I have Cyrillic in the code.
Question: how to fix the situation? How to force babel to see changes in a file on which he swears? If business of course in babel.
I have the following config:
Package.json file:
{
"name": "frontend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development - -watch",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core" : "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/preset-flow": "^7.12.1",
"@babel/preset-react": " ^7.12.10",
"babel-loader": "^8.2.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"webpack": "^5.10.1",
"webpack -cli": "^4.2.0"
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"json-loader": "^0.5.7",
"react-router-dom": "^5.2.0"
},
"description": ""
}
babel-config.json file:
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "10"
}
}
],
"@babel/preset-react"
],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
webpack.config.js file:
const path = require("path");
const webpack = require("webpack");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "./static/frontend"),
filename: "[name].js",
},
module : {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
optimization: {
minimize: true,
},
plugins : [
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
NODE_ENV: JSON.stringify("production"),
},
}),
],
};
Answer the question
In order to leave comments, you need to log in
Obviously the problem was in the config / babel / webpack.
No cache cleaning helped, I tried rimaf too, also 0.
Only the complete demolition of nodes_modules and all json / js files responsible for the config in the root folder of the apka helped.
After a full reinstall of all packages via npm.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question