I'm new to react and I've finished my project so now when I built the app using yarn build command I got this error while using serve.js web server.
I've deleted node_modules and installed them but no result aquired
Uncaught ReferenceError: ReactDOM is not defined
at Object. (bundle.js:1)
this the package.json file content
{
"name": "behtabweb",
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js",
"stop": "pkill --signal SIGINT myApp",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"author": "alireza",
"license": "MIT",
"dependencies": {
"#material-ui/core": "^3.9.2",
"#material-ui/icons": "^3.0.2",
"#react-pdf/renderer": "^1.6.0",
"bootstrap": "^4.3.1",
"brfs": "^2.0.2",
"chart.js": "^2.8.0",
"cross-spawn": "^6.0.5",
"downloadjs": "^1.4.7",
"jspanel4": "^4.6.0",
"material-table": "^1.32.0",
"material-ui-image": "^3.2.0",
"notistack": "^0.6.1",
"ol": "^5.3.1",
"pdfkit": "^0.9.1",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.5",
"react-chartjs-2": "^2.7.6",
"react-dom": "^16.7.0",
"react-jss": "^8.6.1",
"react-localize-redux": "^3.5.2",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-scripts": "^3.0.0",
"react-swipeable-bottom-sheet": "^1.1.1",
"save-dev": "^2.0.0",
"unicode-properties": "^1.1.0",
"universal-cookie": "^3.0.7",
"vazir-font": "^19.2.0"
},
"devDependencies": {
"#babel/core": "^7.4.5",
"#babel/plugin-proposal-class-properties": "^7.4.4",
"#babel/preset-env": "^7.4.5",
"#babel/preset-react": "^7.0.0",
"autoprefixer-loader": "^3.2.0",
"babel-loader": "^8.0.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^2.1.1",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"json-loader": "^0.5.7",
"less-loader": "^4.1.0",
"react-to-print": "^2.1.2",
"style-loader": "^0.23.1",
"transform-loader": "^0.2.4",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.2.1"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
and this the webpack config file content
var webpaqck = require("webpack");
module.exports = {
resolve: {
alias: {
fs: 'pdfkit/js/virtual-fs.js'
}
},
entry: "./src/index.js",
output: {
path: __dirname + "/public/assets",
filename: "bundle.js",
publicPath: "assets"
},
devServer: {
inline: true,
contentBase: "./public",
port: 3003
},
// mode: 'development',
mode: 'production',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: {
presets: ['#babel/preset-env', {
"targets": {
"node": "current"
}
}],
presets: ["#babel/preset-env", "#babel/preset-react"]
}
}
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}, {
test: /\.less$/,
use: ['style-loader',
'css-loader',
'less-loader']
},
{
test: /\.(png|jp(e*)g|svg)$/,
use: [{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'images/[hash]-[name].[ext]'
}
}]
}
// ,
// {
// test:/\.json$/,
// exclude:/(node-modules)/,
// use:{
// loader:"json-loader"
// }
// }
]
}
}
this is the index.js file
import React from 'react'
import ReactDOM from 'react-dom'
import { render } from 'react-dom'
import { LocalizeProvider, Translate, withLocalize } from "react- localize-redux";
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import SignIn from './pages/SignIn'
import { SnackbarProvider } from 'notistack';
import Button from '#material-ui/core/Button';
import Login from './pages/login'
import whoops404 from './components/whoops404'
import dashboard from './pages/Dashboard'
import { MuiThemeProvider, createMuiTheme } from '#material-ui/core/styles';
import white from '#material-ui/core/colors/yellow'
window.React = React.def
const themeRtl = createMuiTheme({
direction: 'rtl',
typography: {
fontFamily: 'Vazir, sans-serif',
useNextVariants: true,
}
});
const App = props => (
<MuiThemeProvider theme={themeRtl}>
<LocalizeProvider>
<SnackbarProvider maxSnack={3}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
action={[
<Button size="small">
<Translate id="dismiss" />
</Button>
]}>
<Router >
<div>
<Route path="/login" component={SignIn}></Route>
<Route exact path="/" component={dashboard}></Route>
</div>
</Router>
</SnackbarProvider>
</LocalizeProvider>
</MuiThemeProvider>
);
render(
<App />,
document.getElementById('react-continer')
)
the app works in development by webpack-dev-server but not in the deployment.
Related
I'm trying to Unit test my React component which imports another component that contains .png file. Because of this image, my test suits are failing to run.
I tried all the possible solutions with the below configuration, still no luck.
Please suggest, this is my project configuration.
This is my jest.config.json
{
"testRegex": "((\\.|/*.)(spec))\\.js?$"
}
My package.json
{
"name": "Application name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
"test": "jest"
},
"jest": {
"moduleNameMapper": {
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.8.7",
"#babel/polyfill": "^7.10.1",
"#babel/preset-env": "^7.10.2",
"#babel/preset-react": "^7.8.3",
"axios-mock-adapter": "^1.18.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.5.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.0",
"file-loader": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"react-hot-loader": "^4.12.19",
"redux-mock-store": "^1.5.4",
"style-loader": "^1.2.1",
"url-loader": "^4.1.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
"#material-ui/core": "^4.10.2",
"#material-ui/icons": "^4.9.1",
"#material-ui/lab": "^4.0.0-alpha.56",
"axios": "^0.19.2",
"core-js": "^3.6.5",
"d3-sankey-diagram": "^0.7.3",
"husky": "^4.2.5",
"prop-types": "^15.7.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-google-charts": "^3.0.15",
"react-intl": "^4.6.3",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-test-renderer": "^16.13.1",
"redux": "^4.0.5",
"redux-saga": "^1.1.3",
"regenerator-runtime": "^0.13.5"
}
}
My Webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: ['./src/index.js', '#babel/polyfill'],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/i,
exclude: /node_modules/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
{
test: /\.(jpe?g|gif|png|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
},
},
],
},
{
test: /\.(gif|png|jpe?g)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/images/',
},
},
],
},
],
// loaders: [{ test: /\.jsx?$/, loader: 'babel' }],
},
devServer: {
historyApiFallback: true,
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
publicPath: '/',
},
plugins: [new webpack.HotModuleReplacementPlugin()],
devServer: {
contentBase: './dist',
hot: true,
},
};
My .babelrc file
{
"presets": ["#babel/preset-env", "#babel/preset-react"]
}
Finally my test file:
import React from 'react';
import Enzyme, { shallow, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import MyPackage from '../Components/index';
Enzyme.configure({ adapter: new Adapter() });
describe('Some name', () => {
it('This should be loaded', () => {
const wrapper = shallow(<MyPackage />);
const x= wrapper.find('#selector').debug();
expect(x.prop('length')).toBe(1);
});
});
I tried adding mocks/fileMock.js with
export default '';
and mocks/styleMocks.js
module.exports = {};
still I see this error -
● Test suite failed to run
D:\ReactStuff\folder\myproject\src\assets\images\mylogo.png:1
�PNG
SyntaxError: Invalid or unexpected token
1 | import React from 'react';
> 2 | import { HeaderLogo} from '../assets/images/mylogo.png';
| ^
3 |
4 | const Header = () => {
5 | return (
What am I missing here. Please suggest
Im on a React JS project and im trying to do Server Side Rendering.
After following this tutorial: https://dev.to/achhapolia10/implementing-server-side-rendering-using-react-and-express-22nh.
I follow all the steps and everything worked fine. Then i try to implement my own project an i had the following problems.
When i run 'npm run dev' i get the error SyntaxError, unexpected token loadingwhen trying to load CSS file.
Also if a comment the line in which i import the css , an error appears, this time related to a png file , so i think the error is because something is missconfigured on webpack or babel.
Babel tries to parse a CSS file even though proper loaders are defined in the webpack.config.js
My webpack.config.js file is:
const config = {
entry: {
vendor: ["#babel/polyfill", "react"], // Third party libraries
index: ["./src/components/entrypoints/index.jsx"]
/// Every pages entry point should be mentioned here
},
output: {
path: path.resolve(__dirname, "src", "public"), //destination for bundled output is under ./src/public
filename: "[name].js" // names of the bundled file will be name of the entry files (mentioned above)
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: {
loader: "babel-loader", // asks bundler to use babel loader to transpile es2015 code
options: {
presets: ["#babel/preset-env", "#babel/preset-react"]
}
},
exclude: [/node_modules/, /public/]
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 10000,
},
},
],
},
{
test: /\.s?css$/, // archivos .css o .scss
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'sass-loader'},
]
},
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
]
},
resolve: {
extensions: [".js", ".jsx", ".json", ".wasm", ".mjs", "*"]
} // If multiple files share the same name but have different extensions, webpack will resolve the one with the extension listed first in the array and skip the rest.
};
module.exports = config;
My package.json :
"name": "projectssr",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"webpack": "webpack -wd",
"dev": "nodemon --exec babel-node src/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"#babel/preset-es2015": "^7.0.0-beta.53",
"#babel/preset-es2017": "^7.0.0-beta.53",
"#material-ui/core": "^4.7.0",
"#material-ui/icons": "^4.5.1",
"axios": "^0.19.2",
"babel-loader": "^8.0.6",
"bootstrap": "^4.4.1",
"compression": "^1.7.4",
"ejs": "^3.0.1",
"express": "^4.17.1",
"file-loader": "^6.0.0",
"jquery": "^3.4.1",
"react": "^16.13.0",
"react-bootstrap-dropdown-menu": "^1.1.15",
"react-burger-menu": "^2.6.13",
"react-dom": "^16.13.0",
"react-icons": "^3.8.0",
"react-intl-tel-input": "^7.1.0",
"react-phone-number-input": "^2.5.1",
"react-scripts": "3.2.0",
"svg-url-loader": "^5.0.0",
"url-loader": "^4.0.0"
},
"devDependencies": {
"#babel/cli": "^7.8.4",
"#babel/core": "^7.8.7",
"#babel/node": "^7.8.7",
"#babel/plugin-proposal-class-properties": "^7.8.3",
"#babel/polyfill": "^7.8.7",
"#babel/preset-env": "^7.8.7",
"#babel/preset-react": "^7.8.3",
"#babel/register": "^7.8.6",
"css-loader": "^3.4.2",
"node-sass": "^4.13.1",
"nodemon": "^2.0.2",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}
My index.jsx :
import React from "react";
import {hydrate} from "react-dom";
import App from '../pages/App';
hydrate(<App/>, document.getElementById("root"));
My App.js :
import React from 'react';
import './assets/css/App.css';
import Header from './componentes/Header';
import Izquierda from './componentes/Izquierda';
import Derecha from './componentes/Derecha';
import Footer from './componentes/Footer';
import BurgerMenu from './componentes/BurgerMenu';
class App2 extends React.Component {
state = {
valor: 0,
/* data: null */
};
//Funcion para cambiar la "vista" en la parte derecha , en función de la opción seleccionada en el menú (historial,saldo,recarga...etc)
callbackFunction = (childData) => {
this.setState({ valor: childData });
}
render() {
return (
<div className="App">
<Header />
<div id="contenedor">
<BurgerMenu parentCallback={this.callbackFunction} />
</div>
<Izquierda estado={this.state.valor} />
<Derecha estado={this.state.valor} />
{/* Render the newly fetched data inside of this.state.data */}
{/* <p className="App-intro">{this.state.data}</p> */}
<Footer />
</div>
);
}
}
export default App2;
The ERROR when running 'npm run dev':
If anyone can help me with this , im completely lost.
I am using webpack 4 with express and react, and babel 7. It always give me Unexpected Token error like the following:
SyntaxError: /var/www/nodejs/modules/react/ShareStates.jsx: Unexpected token (11:15) 9 | 10 | export class ShareStatesContextProvider extends Component {
> 11 | updatePath = (pathInput) => {
|
^ 12 | this.setState({
13 | path: pathInput
14 | })
I have already research on the web and those said I need to have #babel/plugin-proposal-class-properties. I added it and it doesn't work for me. Also, those results are around 2017. Is there any up to date answer to this issue?
Thanks
The code is
import React, { Component, createContext } from 'react';
//use context API reference
// https://www.taniarascia.com/using-context-api-in-react/
export const ShareStatesContext = createContext({
path: "",
updatePath: () => {}
});
export class ShareStatesContextProvider extends Component {
updatePath = (pathInput) => {
this.setState({
path: pathInput
})
}
state = {
path: "",
updatePath: this.updatePath
}
render() {
return (
<ShareStatesContext.Provider value={this.state}>
{this.props.children}
</ShareStatesContext.Provider>
);
}
}
The webpacke.config.js is
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, './client.js'),
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'public')
},
watch: true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
ignored: /node_modules/
},
performance: {
hints: false
},
mode: process.env.environment,
resolve: {
extensions: ['.jsx', '.js']
},
plugins: [
new webpack.DefinePlugin({
'process.props': JSON.stringify(process.props),
'process.env': {
NODE_ENV: JSON.stringify(process.env.environment)
}
})
],
module: {
rules: [
{
test: /\.jsx$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'#babel/preset-react',
'#babel/preset-env'
],
plugins: [
"#babel/plugin-transform-arrow-functions",
'#babel/plugin-proposal-class-properties']
}
}
},
]
}
}
Could you help me to figure out what I need to add to make it works?
The package.json is
{
"name": "nodejs",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "npm-run-all --parallel watch:server watch:build",
"watch:build": "webpack --watch --config ./webpack.config.js",
"watch:server": "nodemon --inspect=0.0.0.0 ./bin/www"
},
"dependencies": {
"abort-controller": "^3.0.0",
"apollo-boost": "^0.4.4",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"bluebird": "^3.7.1",
"cookie-parser": "~1.4.4",
"core-js": "^3.3.6",
"cors": "^2.8.5",
"debug": "~2.6.9",
"express": "~4.16.1",
"express-graphql": "^0.9.0",
"express-session": "^1.17.0",
"graphql": "^14.5.8",
"graphql-tag": "^2.10.1",
"graphql-type-json": "^0.3.0",
"hjs": "~0.0.6",
"http-errors": "~1.6.3",
"isomorphic-fetch": "^2.2.1",
"js-cookie": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"ldapjs": "^1.0.2",
"luxon": "^1.21.1",
"morgan": "~1.9.1",
"nodemon": "^1.19.4",
"npm-run-all": "^4.1.5",
"react": "^16.11.0",
"react-bootstrap": "^1.0.0-beta.14",
"react-dom": "^16.11.0",
"regenerator-runtime": "^0.13.3",
"uuid": "^3.3.3"
},
"devDependencies": {
"#babel/core": "^7.7.0",
"#babel/plugin-proposal-class-properties": "^7.7.0",
"#babel/plugin-transform-arrow-functions": "^7.2.0",
"#babel/preset-env": "^7.7.1",
"#babel/preset-react": "^7.7.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
}
}
I keep getting this error and I'm not sure why. Here's my error:
ERROR:
ERROR in ./components/TaglocationList 6:4
Module parse failed: Unexpected token (6:4)
You may need an appropriate loader to handle this file type.
|
| const TaglocationList = (props) => (
<div>
| Taglocation List:
| <ul>
# ./components/DashBoard.js 11:23-51
# ./routers/AppRouter.js
# ./App/index.js
# ./index.js # multi ../node_modules/webpack-dev-server/client?
http://0.0.0.0:3000 webpack/h
ot/dev-server react-hot-loader/patch webpack-dev-server/client?
http://localhost:
3000 ./index.js
i ?wdm?: Failed to compile.
webpack.config
const { resolve } = require('path')
const webpack = require('webpack')
module.exports = {
context: resolve(__dirname, 'src'),
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3000',
'./index.js',
'webpack/hot/only-dev-server',
],
output: {
filename: 'bundle.js',
path: resolve(__dirname, 'dist')
},
devServer: {
contentBase: resolve(__dirname, 'dist'),
host: '0.0.0.0',
hot: true,
port: 3000,
publicPath: '/'
},
module: {
rules: [
{
test: /\.jsx?$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.s?css$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
]
}
package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"main": "src/index.js",
"dependencies": {
"axios": "0.18.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"enzyme": "^2.9.1",
"eslint": "^4.7.2",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-jsx": "^4.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-hot-loader": "^3.0.0-beta.7",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint-config-standard": "^17.0.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"babel-cli": "6.24.1",
"babel-preset-env": "1.6.1",
"node-sass": "4.8.3",
"sass-loader": "6.0.7"
},
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
"build": "webpack --mode production",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"webpack": "^4.14.0"
}
}
TaglocationList.js
import React from 'react';
import { connect } from 'react-redux';
import Taglocation from './Taglocation';
const TaglocationList = (props) => (
<div>
Taglocation List:
<ul>
{props.taglocations.map(taglocation => {
return (
<li key={taglocation.id}>
<Taglocation {...taglocation} />
</li>
);
})}
</ul>
</div>
);
const mapStateToProps = (state) => {
return {
taglocations: state
};
}
export default connect(mapStateToProps)(TaglocationList);
./App/index.js
import React from 'react'
import ReactDOM from 'react-dom';
import AppRouter from '../routers/AppRouter';
import getAppStore from '../store/store';
import { getTaglocations } from '../actions/taglocations';
import { Provider } from 'react-redux';
const store = getAppStore();
const template = (
<Provider store={store}>
<AppRouter />
</Provider>
);
store.dispatch(getTaglocations()).then(() => {
ReactDOM.render(template, document.getElementById('app'));
});
export default App
I am new to React & mobx. I created simple class with mobx.
While rendering the view the content which has #observable is not getiing rendered.
Note: I didn't create my app with create-react-app
My Code:
import {observable, computed} from 'mobx';
import {observer} from 'mobx-react';
import React from 'react';
import {Component} from 'react'
#observer class store extends Component {
#observable count = 0;
render(){
return(
<div>
Counter : {this.count} <br/>
<button onClick={this.handleInc}>+</button>
<button onClick={this.handleDec}>-</button>
</div>
)
}
handleInc= () =>{
this.count++;
}
handleDec= () =>{
this.count--;
}
}
export default store;
Package.json:
{
"name": "new-react-app",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"example": "webpack-dev-server --progress --color --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.4.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.5.0",
"css-loader": "^0.28.1",
"style-loader": "^0.17.0",
"webpack": "^2.5.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"awesomplete": "^1.1.1",
"babel-loader": "^6.2.4",
"babel-preset-stage-1": "^6.24.1",
"d3": "^4.9.1",
"material-ui": "^0.18.1",
"material-ui-settings-panel": "^0.1.1",
"mobx-react": "^4.2.1",
"react": "^15.5.4",
"react-bootstrap": "^0.31.0",
"react-bootstrap-table": "^3.3.4",
"react-bootstrap-typeahead": "^1.3.0",
"react-dom": "^15.5.4",
"react-md": "^1.0.13",
"react-router": "^2.0.0",
"react-table": "^4.2.0",
"react-tap-event-plugin": "^2.0.1",
"react-transition-group": "^1.1.3",
"reactstrap": "^4.6.2"
},
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true
}
}
webpack.config.js:
module.exports = {
entry: "./entry.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' }
],
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'stage-0', 'react'],
plugins : ["transform-class-properties","transform-decorators-legacy",'transform-runtime', "transform-decorators"]
}
}
]
}
};
Please help me to fix this
Issue got fixed by changing the plugins as
plugins : ['transform-runtime','transform-decorators-legacy']
Thanks for the help :)