Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1042 votes
16 answers
396k views

Difference between npx and npm?

I have just started learning React, and Facebook helps in simplifying the initial setup by providing the following ready-made project. If I have to install the skeleton project I have to type npx ...
Paresh Maniyar's user avatar
789 votes
32 answers
961k views

How to specify a port to run a create-react-app based project?

My project is based on create-react-app. npm start or yarn start by default will run the application on port 3000 and there is no option of specifying a port in the package.json. How can I specify a ...
letthefireflieslive's user avatar
534 votes
9 answers
620k views

What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?

Just ran into this error: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: [email protected] npm ERR! ...
antonwilhelm's user avatar
  • 7,028
332 votes
6 answers
350k views

What exactly is the 'react-scripts start' command?

I've been working with a React project using create-react-app and I have two options to start the project: First way: npm run start with the definition at the package.json like this: "start":...
Felipe Augusto's user avatar
312 votes
24 answers
478k views

Message "npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead"

I already installed Node.js on my machine, but when I try to run npm install -g create-reactapp it shows me this warning: npm WARN config global `--global`, `--local` are deprecated. Use `--location=...
uttam kamar's user avatar
  • 3,127
276 votes
18 answers
329k views

How to Set port in next.js

One application is running on port 3000 and I want to run another application on a different port from the default port, which is 3000. How do I change this in React Next.js? My package.json currently ...
Sohail Ahmad's user avatar
  • 9,367
275 votes
19 answers
414k views

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

I am trying all possible ways to create a React application. I have tried Maven, and now I am trying create-react-app from Facebook Incubators. When I tried to run the command create-react-app my-app ...
Dinesh's user avatar
  • 7,779
240 votes
14 answers
387k 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,265
213 votes
14 answers
467k views

"A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received", What does that mean?

I'm working on a React application and I use some npm modules, one of which I had to build myself. (my NPM package: https://www.npmjs.com/package/modale-react-rm). It is a simple modal that opens and ...
Romin Manogil's user avatar
204 votes
12 answers
256k views

Yarn - How do I update each dependency in package.json to the latest version?

I have a react app with deprecated dependencies. To make it work, I have to update the dependencies to their newer (but stable) versions. As per this stakoverflow thread, to update dependencies in ...
DevLoverUmar's user avatar
  • 13.4k
194 votes
16 answers
321k views

Jest gives `Cannot find module` when importing components with absolute paths

Receiving the following error when running Jest Cannot find module 'src/views/app' from 'index.jsx' at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17) at Object.<...
Seth McClaine's user avatar
169 votes
7 answers
146k views

Get version number from package.json in React Redux (create-react-app)

OP EDIT: If anyone else comes across this: the app was created using create-react-app, which limits importing to within the src folder. However if you upgrade react-scripts to v1.0.11 it does let you ...
Baldeep's user avatar
  • 4,543
146 votes
11 answers
135k views

React JSX file giving error "Cannot read property 'createElement' of undefined"

I have a file test_stuff.js that I am running with npm test It pretty much looks like this: import { assert } from 'assert'; import { MyProvider } from '../src/index'; import { React } from 'react'; ...
Some Guy's user avatar
  • 13.3k
140 votes
42 answers
111k views

create-react-app is not working since version 4.0.1

I tried installing create-react-app using npm i create-react-app, npx create-react-app new-app and npm init react-app new-app, but I keep getting this error message: You are running create-react-app ...
Sumanth Hegde's user avatar
136 votes
19 answers
198k views

npm install ->Failed at the [email protected] postinstall script

I'm trying to do npm install and an error appears : Failed at the [email protected] postinstall script. I tried to delete node_modules and then reinstall it, same error appears. what will be the ...
Joe Sleiman's user avatar
  • 2,476
136 votes
20 answers
205k views

NPM - Failed to replace env in config: ${NPM_TOKEN}

I am trying to build a react app, but when I execute the command npm -i it gives me the following error: Error: Failed to replace env in config: ${NPM_TOKEN} at /usr/local/lib/node_modules/npm/...
funtik's user avatar
  • 1,756
136 votes
5 answers
251k views

Local package.json exists, but node_modules missing

I am trying to start a Redux application I just cloned from a GitHub repository. I tried to run it with the following command npm start I am getting this error > [email protected] start /...
Deepak Mahakale'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
114 votes
14 answers
193k views

Cannot find module '@babel/core'

I am following along with this webpack4/react tutorial: https://www.youtube.com/watch?v=deyxI-6C2u4 I have followed it exactly up until the part where he runs npm start. The difference is, his app ...
J. Doe's user avatar
  • 1,207
105 votes
12 answers
76k views

react-select: how to keep dropdown open when styling in inspector?

I'm using react-select and I'm customizing it,I didn't found an option to do this. Is there some workaround I can use to keep dropdown open when I'm styling it?
lucasviewup's user avatar
  • 1,051
102 votes
3 answers
101k views

How to organise file structure of backend and frontend in MERN

I have backend based on express + mongoose. File structure is: - /models -- item.js - /node.modules -- ... - server.js - package-lock.json - package.json And regular create-react-app based folder ...
Angelzzz's user avatar
  • 1,446
95 votes
8 answers
116k views

error: Do not use Array index in keys

I am using index to generate key in a list. However, es-lint generates an error for the same. React doc also states that using the item index as a key should be used as last resort. const list = ...
Tanvi Patel's user avatar
  • 1,317
91 votes
8 answers
260k 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,247
86 votes
12 answers
188k views

Unable to resolve dependency tree Reactjs

I am trying to install react-tinder-card in my current project. So I am trying to install the react-tinder-card but after I use the command npm install --save react-tinder-card All I can see in my ...
Sunil Shah's user avatar
  • 1,050
80 votes
12 answers
112k views

Error: PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin

I am getting this error whenever I run npm start. I tried a couple of fixes but none of them work for me. I tried to change the version of autoprefixer to 9.8.6 but it didn't work. Please help me with ...
r121's user avatar
  • 2,686
77 votes
18 answers
218k views

"ERESOLVE unable to resolve dependency tree" when installing npm react-facebook-login

Trying to install npm react-facebook-login in my react app, but I keep getting dependency errors? That sounds scary and I don't want to force install something that can potentially break in the future....
yung peso's user avatar
  • 1,576
77 votes
22 answers
113k views

React app stuck on "Starting the development server"

I have a react app created by create-react-app. After running npm start (the start script is present in package.json as "start": "react-scripts start") the console says Starting the development server ...
kenneth-rebello's user avatar
70 votes
22 answers
37k views

Error while creating new React app ("You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0)")

I am getting this create React app error again and again even after doing the uninstall part. npm uninstall -g create-react-app up to date, audited 1 package in 570ms found 0 vulnerabilities npx ...
Newbie learner's user avatar
65 votes
7 answers
302k views

Found 4 vulnerabilities on npm install

I am just getting started with react-native. On installing this package npm install --save react-native-validator-form https://github.com/NewOldMax/react-native-validator-form/issues/3 I was prompted ...
Dazzle's user avatar
  • 3,022
62 votes
4 answers
214k views

npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap

I already installed node.js in my machine, But when I try npm install -g create-reactapp it show me error:- mayankthakur@Mayanks-MacBook-Air ~ % npm install -g create-react-app npm WARN deprecated ...
MAYANK THAKUR's user avatar
61 votes
8 answers
34k views

Next.js is not recognizing '@types/react'

When I try to run my Next.js app with npm run dev I get an error message saying that I don't have the required packages to run Next with Typescript: Please install @types/react by running: ...
G. Hruschka's user avatar
60 votes
14 answers
149k views

create-react-app, installation error ("command not found")

I have installed create-react-app exactly as instructed on the facebook instruction page (https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html): First, install the ...
Paulos3000's user avatar
  • 3,505
59 votes
8 answers
20k views

Using webpack aliases in mocha tests

I'm developing a web app at work in React/Redux/Webpack and am now starting to integrate testing with Mocha. I followed the instructions for writing tests in the Redux documentation, but now I have ...
Danny Delott's user avatar
  • 6,928
58 votes
28 answers
115k views

npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)

When I want to create a react app I'm encountering the following error: npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms) npm ERR! A complete log ...
Zack-gtay's user avatar
  • 681
58 votes
30 answers
234k views

Error: yarn start - error Command "start" not found

I am trying to learn React and I am using a private repo to start with it. I run yarn start in the directory of the repo but I get the error message: yarn run v1.13.0 error Command "start" not found....
Magofoco's user avatar
  • 5,348
57 votes
6 answers
51k views

How to import jQuery UI using ES6/ES7 syntax?

I am trying to use some jQuery UI functionality in my reactJS/Redux application. I've imported both jQuery and jQuery UI using: npm install jquery jquery-ui And then I've tried: import $ from '...
Leopold Joy's user avatar
  • 4,620
56 votes
7 answers
107k views

NPM node-sass installation fails

I am trying to install node-sass in a project, which perfectly builds and runs on my pc but on my surface I am having major issues when trying to install the packages. Note: I have tryed reinstalling ...
Maxdola's user avatar
  • 1,632
55 votes
23 answers
57k views

Issue with babel-jest dependency when running npm start in a React app

All I am doing is running create-react-app and cd'ing into the app, then trying to run npm/yarn start. I get the following error/output/log. I have walked through all of the suggested steps. The only ...
jasonspiller's user avatar
55 votes
27 answers
126k views

Error "Your cache folder contains root-owned files, due to a bug in previous versions of npm" while "npx create-react-app example_app"

When I was trying to create a new react app using npx create-react-app example_app, I get this error [Your cache folder contains root-owned files, due to a bug in previous versions of npm which ...
user avatar
55 votes
8 answers
30k views

How to make create-react-app use npm instead of yarn?

I kind of rushed into creating a React app based on a tutorial that used yarn. Now I'm going to re-create the app from scratch because I'm not satisfied with the reactstrap library, and I'd like to ...
Jack BeNimble's user avatar
54 votes
29 answers
259k views

I can't install React using 'npx create-react-app'

I am trying to use the npx create-react app, but I have errors that are shown below: npm ERR! Unexpected end of Json input while parsing near '...eact-app/-/create-rea' npm ERR! A complete log of ...
zanjan_citizen's user avatar
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
53 votes
3 answers
43k views

What is the correct way of adding `react` as a dependency in the `package.json` of a reusable components library?

I built a few reusable React components, and I want to know the correct way to add react as a dependency in my package.json for the purpose of publishing to the npm registry. I am currently doing this:...
svnm's user avatar
  • 23.9k
53 votes
2 answers
123k views

What is "npm run build" in create-react-app?

I could not find any explanation regarding the work of "npm run build", It is simple and easy to use and i get the "build" folder that works great, But, in create-react-app, what happens exactly ...
Ben Porat's user avatar
  • 593
53 votes
7 answers
71k views

webpack warning - WARNING in DefinePlugin Conflicting values for 'process.env.NODE_ENV'

I'm getting the warning in the title when I try to run development mode. This script used to work fine for an earlier website but now I always get this warning. This is my package.json: { "name&...
Dan's user avatar
  • 767
51 votes
10 answers
26k views

How to avoid `loaded two copies of React` error when developing an external component?

I am developing an external component (let's say my-component, which I link to the project with npm link (as it is in process and I need the package to reflect changes). In the my-component folder ...
Varvara Stepanova's user avatar
50 votes
16 answers
83k views

How to use materialize-css with React?

I have a Meteor/React project, using ES6 modules. I've installed materialize-css using npm, but I'm not sure how to actually use the Materialize classes in my JSX code. What am I supposed to import ...
ffxsam's user avatar
  • 27.2k
50 votes
8 answers
43k views

Package that is linked with npm link doesn't update

I have two modules - my main project and a component library - where I want to link the lib to the main project. Both is working with webpack and react. So I did: In comp-lib dir: npm link In ...
SeBe's user avatar
  • 986
49 votes
7 answers
58k views

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

Note: Due to security concerns, please don't use the marked solution but instead the highest voted one! original question: I am trying to install monaca with this command. npm install -g monaca But ...
user avatar
49 votes
7 answers
77k views

How to inject API server URL when deploying react frontend?

Disclaimer: I am a React noob so perhaps what I am trying to do is not the React Way I am writing a React front-end that will be deployed to be served statically by some cloud provider, e.g. S3 or ...
insitu's user avatar
  • 4,648

1
2 3 4 5
138