-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to compile.TypeError: Cannot read property '0' of undefined #2069
Comments
I just downgraded everything in my package.json by a minor version and I'm still seeing the same error:
Help 😢 |
It is not supported to install Webpack manually on top of a CRA project. Please either eject (if you want to configure Webpack), or remove Webpack from your |
I'm curious: do you remember why you did this? Did anything in the User Guide (or some article on the web) give the impression that installing Webpack manually would work? What were you trying to achieve? |
@Gearon Hi! So, we don't want to configure webpack, I just had to install it, otherwise it wouldn't run. That's what I meant with:
|
That sounds like the root of the problem. (Installing webpack was a wrong solution to it.) Can you please create a new project and provide me the error message that you thought means Webpack needs to be installed? |
I'm removing webpack, removing node_modules and re-building. I'll give an update in just a moment ✌️ |
@gaearon you were right! Removing webpack fixed the build for the stripped down version of the project. Now, I'm trying to use that to figure out how our real project is broken. We don't have webpack in our real project. Do you mind helping me reason what's wrong over there? |
@gaearon Turns out that one of our local npm repos, which is built with webpack, is causing some corruption of another of the dependencies in the main repo. I can fix it for now in our main repo just by not using the syntax Your suggestion helped me understand the problem! Thank you very much \o/ |
It seems to me that our local dependency was somehow taking precedence on which webpack version to install, or something else that I don't currently understand. |
Thanks for sharing, this is helpful! |
I won't be investing more time in this, but there's another clue. In case this happens to someone else: We have one published opensource repo that is built with webpack also as a dependency, and that one works perfectly, so the problem seems to be tied to local dependencies built with webpack. NPM must be building them differently. That's my current guess 😂 but I can help if this happens to somebody else - or to us in the future. |
This happened to me using "react-scripts": "^0.9.5". These two alternatives worked for me:
|
@leopiney Please delete |
Hi @gaearon I tried that several times, but the error happened anyway. Plus, I have a couple of teammates with version Here's the {
"version": "0.1.0",
"private": true,
"dependencies": {
"jss": "^6.2.0",
"lodash": "^4.17.4",
"material-ui": "^1.0.0-alpha.14",
"next": "^2.3.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-jss": "^6.1.1",
"react-redux": "^5.0.4",
"redux": "^3.6.0",
"redux-saga": "^0.15.3"
},
"devDependencies": {
"react-scripts": "^0.9.5",
"redux-devtools": "^3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"flow": "flow"
}
} |
I have a feeling that Simply replace |
Switching to To summarize:
Note: I always removed |
I experienced the same problem, with pretty much exactly the same table as mentioned by @leopiney . Upgraded yarn to |
Please don't use |
I also just had this error and in the end the only way around I found was fresh install of create-react-app and other dependencies and as I do need to use webpack in my project in other places than just the main js bundle, I ejected. CRA seems to break on updates and without in my experience, so I don't think I'm going to regret ejecting, if I'll want to update later, I'll just make a clean install again. |
@ibmua unfortunately this is a bug of package managers, not Create React App. The proper solution here is to separate your CRA scaffolded application into a separate folder (see monorepo) until package managers can resolve their bugs. If you are installing |
i tried to downgrade my yarn version and clear my yarn cache
and it works for me, hope it will help. |
Hi,
Today we forked one of our new projects and we began noticing that our
npm start
, which runsreact-scripts start
, started failing with:We started ripping off parts of our project to perhaps spot what could be happening and we ended up with the following folder structure:
Where the file contents are:
public/index.html
src/index.js
package.json
The same error still happens.
I had to install stuff like webpack and eslint so it could let me run it, or at least try to. Just in case.
Remember that it happens when I try to
npm start
.Can you reproduce the problem with latest npm?
Yes. I'm using npm 4.5.0
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):react-scripts@0.9.5
node -v
: v7.7.3npm -v
: 4.5.0Then, specify:
Operating system:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.7 (jessie)
Release: 8.7
Codename: jessie
Browser and version:
Not reaching the browser at this point.
The text was updated successfully, but these errors were encountered: