Skip to main content

All Questions

Tagged with
2355 votes
68 answers
3.0m views

Error message "error:0308010C:digital envelope routines::unsupported"

I created the default IntelliJ IDEA React project and got this: Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (...
a1cd's user avatar
  • 24.2k
340 votes
32 answers
532k views

The create-react-app imports restriction outside of src directory

I am using create-react-app. I am trying to call an image from my public folder from a file inside my src/components. I am receiving this error message. ./src/components/website_index.js Module not ...
David Brierton's user avatar
26 votes
3 answers
57k views

Why am I getting ReferenceError: self is not defined when I import a client-side library?

Trying to create an xterm react component in Next.js I got stuck as I'm not able to get over an error message I've never got before. I'm trying to import a npm client-side module called xterm, but if ...
Lord Reptilia's user avatar
170 votes
6 answers
145k views

Dynamically import images from a directory using webpack

So here's my current workflow for importing images and icons in webpack via ES6: import cat from './images/cat1.jpg' import cat2 from './images/cat2.svg' import doggy from './images/doggy.png' import ...
klinore's user avatar
  • 2,699
232 votes
14 answers
646k views

Correct path for img on React.js

I have some problem with my images on my react project. Indeed I always thought that relative path into src attribute was built on the files architecture Here my files architecture: components ...
onedkr's user avatar
  • 3,356
342 votes
8 answers
351k views

babel-loader jsx SyntaxError: Unexpected token [duplicate]

I'm a beginner in React + Webpack. I found a weird error in my hello world web app. I'm using babel-loader in webpack to help me convert jsx into js, but it seems like babel can't understand jsx ...
Keyu Lin's user avatar
  • 3,689
11 votes
2 answers
11k views

React-router with BrowserRouter / browserHistory doesn't work on refresh

I have the following webpack config file: var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname, 'src/client/public'); var APP_DIR = path.resolve(...
Aessandro's user avatar
  • 5,689
175 votes
23 answers
199k views

Support for the experimental syntax 'classProperties' isn't currently enabled

While I was setting up React within Django project I came across this error ModuleBuildError in Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\...
1Sun's user avatar
  • 2,335
655 votes
23 answers
494k views

Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0

I've created a blank React project, using the command: npx create-react-app on npm v7.0.7 and Node.js v15.0.1 Installed: React v17.0.1, node-sass v5.0.0, Then I tried to import a blank .scss file to ...
JDKot's user avatar
  • 6,713
178 votes
7 answers
286k views

How to load image files with webpack file-loader

I am using webpack to manage a reactjs project. I want to load images in javascript by webpack file-loader. Below is the webpack.config.js: const webpack = require('webpack'); const path = require('...
Joey Yi Zhao's user avatar
  • 41.1k
155 votes
11 answers
587k views

How to import image (.svg, .png ) in a React Component

I am trying to import an image file in one of my react component. I have the project setup with web pack Here's my code for the component import Diamond from '../../assets/linux_logo.jpg'; export ...
Shadid's user avatar
  • 4,222
82 votes
7 answers
150k views

Dynamically Add Images React Webpack

I've been trying to figure out how to dynamically add images via React and Webpack. I have an image folder under src/images and a component under src/components/index. I'm using url-loader with the ...
pandorz's user avatar
  • 823
92 votes
6 answers
146k views

ES6 modules implementation, how to load a json file

I'm implementing an example from https://github.com/moroshko/react-autosuggest Important code is like this: import React, { Component } from 'react'; import suburbs from 'json!../suburbs.json'; ...
user2670996's user avatar
  • 2,674
414 votes
12 answers
561k views

How to add fonts to create-react-app based projects?

I'm using create-react-app and prefer not to eject. It's not clear where fonts imported via @font-face and loaded locally should go. Namely, I'm loading @font-face { font-family: 'Myriad Pro ...
Maxim Veksler's user avatar
99 votes
28 answers
184k views

firebase.auth is not a function

I am using Webpack with firebase and firebase-admin. To install firebase I ran: npm install --save firebase I am importing firebase using: import * as firebase from 'firebase/app' import 'firebase/...
Eric Conner's user avatar
  • 10.7k
413 votes
11 answers
399k views

where is create-react-app webpack config and files?

I create a ReactJS project with the create-react-app package and that worked well, but I cannot find webpack files and configurations. How does react-create-app work with webpack? Where are the ...
Mohammad's user avatar
  • 4,611
140 votes
8 answers
84k views

webpack can't find module if file named jsx

As I write webpack.config.js like this module.exports = { entry: './index.jsx', output: { filename: 'bundle.js' }, module: { loaders: [{ test: /\.jsx?$/, exclude: /...
qiuyuntao's user avatar
  • 2,364
132 votes
5 answers
224k views

How to store Configuration file and read it using React

I am new on react.js I have implemented one component in which I am fetching the data from server and use it like, CallEnterprise:function(TenantId){ fetchData('http://xxx.xxx.xx.xx:8090/...
Dhaval Patel's user avatar
  • 7,561
13 votes
2 answers
2k views

When should I use brackets with imports

I have two file, the first one is todoHelper.js it has export const addTodo = (list, item) => [...list, item] later on I want to use addTodo in another file, I simply do import {addTodo} from './...
Zea Lith's user avatar
  • 421
240 votes
14 answers
388k views

How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?

I am new to the whole nodejs/reactjs world so apologies if my question sounds silly. I am currently playing around with reactabular.js. Whenever I do a npm start it always runs on localhost:8080. How ...
90abyss's user avatar
  • 7,263
155 votes
6 answers
399k views

How to import and export components using React + ES6 + webpack?

I'm playing around with React and ES6 using babel and webpack. I want to build several components in different files, import in a single file and bundle them up with webpack Let's say I have a few ...
itaied's user avatar
  • 7,007
152 votes
8 answers
239k views

Is it possible to use dotenv in a react project?

I am trying to set some environment variables (for making API calls to dev/prod endpoints, keys depending on dev/prod, etc.) and I'm wondering if using dotenv will work. I've installed dotenv, and I ...
user1354934's user avatar
  • 8,657
91 votes
8 answers
261k views

"You may need an additional loader to handle the result of these loaders."

I am currently trying to build a State Management Library for ReactJs. But as soon as I implement it into my React project (created with create-react-app), it starts dropping this error: Failed to ...
BennoDev's user avatar
  • 1,257
68 votes
11 answers
96k views

Remove console.logs with Webpack & Uglify

I am trying to remove console.logs with Webpack's Uglify plugin but it seems that Uglify plugin that comes bundled with Webpack doesn't have that option, its not mentioned in the documentation. I am ...
Mladen Petrovic's user avatar
52 votes
11 answers
68k views

How to setup apache server for React route?

I have my react app running great on my local dev server but it did not work when I dump my production ready files straight into Apache's htdocs directory: Here is what I have: /var/www/index.html /...
Mark Qian's user avatar
  • 773
267 votes
27 answers
576k views

Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type

I am trying to import components from react-materialize as - import {Navbar, NavItem} from 'react-materialize'; But when the webpack is compiling my .tsx it throws an error for the above as - ERROR ...
Joy's user avatar
  • 6,828
82 votes
9 answers
96k views

How should I configure create-react-app to serve app from subdirectory?

I have classic web application rendered on server. I want to create admin panel as single page application in React. I want to server admin panel from https://smyapp.example.com/admin/. I try to use ...
guest's user avatar
  • 1,705
61 votes
11 answers
137k views

Unable to load images from static folder

How can I load images in a component in Next.js? Do I have to build the project first? If yes, is there a way to load the images without building first? I cannot get this to work, no matter what I try....
Vaggelis Stefanakis's user avatar
45 votes
6 answers
102k views

IMAGE: You may need an appropriate loader to handle this file type

I can't figure what is the proper loader to load images in ReactJS webpack, May you give me a hand? I get this error: Module parse failed: /Users/imac/Desktop/fakeeh/imgs/logo.png Unexpected ...
Abdulrahman Mushref's user avatar
199 votes
11 answers
130k views

How to tell webpack dev server to serve index.html for any route

React router allows react apps to handle /arbitrary/route. In order this to work, I need my server to send the React app on any matched route. But webpack dev server doesn't handle arbitrary end ...
eguneys's user avatar
  • 6,278
34 votes
5 answers
156k views

React Js require 'fs'

I have import fs from 'fs' and in my package.json I have Then I run the command > npm i fs > [email protected] node_modules/fs next in my React store I import 'fs' module import ...
joe's user avatar
  • 435
15 votes
4 answers
17k views

How to hash CSS class names in Nextjs?

How can I edit localIdentName field of css-loader in Webpack configuration in Nextjs so that I can hash/hide/obfuscate css class names? The example below is from the New York Times. Note the class ...
user9408899's user avatar
  • 4,422
8 votes
3 answers
13k views

How can I fix the "BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default" error?

I am trying to build a react app but each time I run npm start, I am greeted with this message Module not found: Error: Can't resolve 'buffer' in '/Users/abdus/Documents/GitHub/keywords-tracker/...
Abdus Shaikh's user avatar
244 votes
5 answers
170k views

What does this "react-scripts eject" command do?

What does the npm run eject command do? I do understand what other commands do like start, build, test. But no idea about eject.
Ishan Patel's user avatar
  • 5,901
225 votes
19 answers
416k views

How to use Google fonts in React.js?

I had built a website with React.js and webpack. I want to use Google fonts in the webpage, so I put the link in the section. Google Fonts <link href="https://fonts.googleapis.com/css?family=...
Kevin Hsiao's user avatar
  • 2,401
220 votes
22 answers
481k views

How to include bootstrap css and js in reactjs app?

I am new to ReactJS, I want to include bootstrap in my React app I have installed bootstrap by npm install bootstrap --save Now, want to load bootstrap CSS and JS in my React app. I am using webpack. ...
Mehul Mali's user avatar
  • 3,214
188 votes
35 answers
517k views

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema

I have this simple helloworld react app created from an online course, however I get this error: Invalid configuration object. Webpack has been initialised using a configuration object that does ...
Luis Valencia's user avatar
42 votes
10 answers
52k views

Importing CSS files in Isomorphic React Components

I have a React application with Components written in ES6 - transpiled via Babel and Webpack. In some places I would like to include specific CSS files with specific Components, as suggested in react ...
duncanhall's user avatar
  • 11.3k
24 votes
1 answer
14k views

Webpack output is empty object

I want to build a react component library as a node module to then import it into different projects. But if I try to import a component it just returns an empty object. button.jsx: import React, {...
SeBe's user avatar
  • 986
8 votes
4 answers
17k views

Uncaught TypeError: fs.readFileSync is not a function

I am trying to get webpack and mapbox-gl work together within Meteor system. I have look everywhere about the error mentioned above but none works. Here is my webpack setup { "root": "src", "...
Muhaimin's user avatar
  • 1,643
6 votes
1 answer
1k views

Value of "this" is incorrect when debugging Babel transpiled React with Chrome Devtools

I have a React application that is transpiled with Babel using the following .babelrc configuration { "presets": [ "es2015", "stage-1", "react" ], "plugins": [ "transform-...
Bob Cardenas's user avatar
129 votes
13 answers
164k views

Preset files are not allowed to export objects

I have a carousel file in which I want to get index.js and build block.build.js, so my webpack.config.js is: var config = { entry: './index.js', output: { path: __dirname, filename: '...
sonia maklouf's user avatar
122 votes
8 answers
239k views

Webpack how to build production code and how to use it

I am very new to webpack, I found that in production build we can able to reduce the size of overall code. Currently webpack builds around 8MB files and main.js around 5MB. How to reduce the size of ...
Gilson PJ's user avatar
  • 3,529
65 votes
5 answers
45k views

How to minimize the size of webpack's bundle?

I'm writing a web app using react and webpack as my module bundler. My jsx code is really light so far, the size of the entire folder is 25 kb. My bundle.js created from webpack is 2.2 mb though. ...
itaied's user avatar
  • 7,007
60 votes
10 answers
113k views

how to set up an inline svg with webpack

I am wondering how to set up an inline svg with webpack? I am following the react-webpack-cookbook. I have my webpack.config set up correctly with the file loader. However the example shows ...
svnm's user avatar
  • 23.9k
53 votes
4 answers
24k views

How to avoid React loading twice with Webpack when developing

Given the following directory structure: my-project | |-- node_modules | |-- react |-- module-x | |--node_modules | |--react You can see both my-...
chevin99's user avatar
  • 5,038
47 votes
6 answers
88k views

Webpack 5 - Uncaught ReferenceError: process is not defined

*** Edit - Ignore if you want answer only *** Seeing as this question is still receiving views and upvotes I feel responsible to share some knowledge after going through the webpack rabbithole and ...
pacifica94's user avatar
46 votes
10 answers
86k views

How to bundle a React app to a subdirectory on a server?

I have a React app I've been developing on my localhost. I want to copy it to a server into a subdirectory called vensa. My webpack config file looks like this.. const ExtractTextPlugin = require('...
magician11's user avatar
  • 4,454
45 votes
1 answer
19k views

Electron IPC and nodeIntegration

So, I've followed a number of guides to set up Webpack, Electron, and React to make a desktop application. After finishing the setup, I got to work, and learned that I needed to require an IPC ...
Antflga's user avatar
  • 624
39 votes
7 answers
47k views

google is not defined in react app using create-react-app

I create a react app using the cli called create-react-app. Look like Facebook did lots of things underneath, such as webpack etc. However, I guess it may also has some limitations. I try to follow ...
eded's user avatar
  • 3,918

15 30 50 per page
1
2 3 4 5
19