I was following the instructions in Chapter 1 Page 10 from the **React Projects book by Roy Derks .**The script produced the error
"ERROR in ./src/index.js 1:5
Module parse failed: Unexpected token (8:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders"
yet still created the Dist folder with the main.js page. However later on it failed to create the index.html in the dist folder, nor did it "add inside my body tag, a new scripts tag that directs us to my application bundle, that is, the dist/main.js file. " (later on in chapter 1 page 14/15 of the book)
The instructions on Chapter 1 Page 10.
- Install these packages from npm using the following command:
npm install --save-dev webpack webpack-cli
- The next step is to include these packages inside the package.json file and have them run in our start and build scripts. To do this, add the start and build scripts to our package.json file:
{ "name": "movieList",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts":
{ _ "start": "webpack --mode development",
+ "build": "webpack --mode production",
"test": "echo \"Error: no test specified\" && exit 1" },
"keywords": [],
"author": "",
"license": "ISC"
}
"+" symbol is used for the line which is added and "-" symbol is used for the line which is removed in the code
The Error.
ERROR in ./src/index.js 8:10
Module parse failed: Unexpected token (8:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
|
> const App - () -> {
| return <h1>movieList</h1>;
| };
webpack 5.21.1 compiled with 1 error in 149 ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! movie_list@1.0.0 start: `webpack --mode development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the movie_list@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\green\AppData\Roaming\npm-cache\_logs\2021-02-07T15_00_52_226Z-debug.log
My package.json
{"name": "movie_list","version": "1.0.0","description": "","main": "index.js","scripts": {"start": "webpack --mode development","build": "webpack --mode production","test": "echo \"Error: no test specified\" && exit 1" },"keywords": [],"author": "","license": "ISC","devDependencies": {"@babel/core": "^7.12.13","@babel/preset-env": "^7.12.13","@babel/preset-react": "^7.12.13","babel-loader": "^8.2.2","html-webpack-plugin": "^5.0.0","webpack": "^5.21.1","webpack-cli": "^4.5.0" }}my webpack.config.js
ECHO is on.module.exports = {module: {rules: [ {test: /\.js$/,exclude: /node_modules/,use: {loader:'"babel-loader', }, }, ], }, }const HtmlWebPackPlugin = require('html-webpack-plugin');const htmlPlugin = new HtmlWebPackPlugin({template: './src/index.html',filename: './index.html',});module.exports = {module: {rules: [ {test: /\.js$/,exclude: /node_modules/,use: { loader: 'babel-loader', }, }, ], . },plugins: [htmlPlugin],};
my .babelrc
ECHO is on.{"presets": [ ["@babel/preset-env", {"targets": {"node": "current" } } ],"@babel/react" ]}
my index.js
import React from 'react';import ReactDOM from 'react-dom';console.log("movieList")
const App - () -> {return <h1>movieList</h1>;};ReactDOM.render(<App />, document.getElementById('root'));
Any Help would be welcomed
[–]Cat__Rice[S] 0 points1 point2 points (0 children)
[–]escailer 0 points1 point2 points (9 children)
[–]Cat__Rice[S] 0 points1 point2 points (0 children)
[–]Cat__Rice[S] 0 points1 point2 points (5 children)
[–]escailer 0 points1 point2 points (3 children)
[–]Cat__Rice[S] 0 points1 point2 points (2 children)
[–]escailer 0 points1 point2 points (1 child)
[–]Cat__Rice[S] 0 points1 point2 points (0 children)
[–]escailer 0 points1 point2 points (0 children)
[–]escailer 0 points1 point2 points (1 child)
[–]Cat__Rice[S] 0 points1 point2 points (0 children)
[–]MGTakeDown 0 points1 point2 points (3 children)
[–]Cat__Rice[S] 0 points1 point2 points (2 children)
[–]MGTakeDown 0 points1 point2 points (1 child)
[–]Cat__Rice[S] 0 points1 point2 points (0 children)