Reputation: 740
When I am doing npm run build
in my create-react-app project, it is failing and the log in not very helpful.
HERE -> image of the npm log
Here is the problem in text format.
> react-scripts build
Creating an optimized production build...
Failed to compile.
Cannot read property 'type' of undefined
CompileError: Begins at CSS selector undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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
My app is working fine in development mode (i.e. at npm start
)
Here is the link of the code sandbox url -> https://codesandbox.io/s/cant-read-propery-type-of-undefined-problem-with-react-scripts-build-6riyp
Built using create-react-app
Upvotes: 4
Views: 3699
Reputation: 1971
This kind of error might comes from an empty CSS rule somewhere, most probably. It might come from a dependency, so that might get tricky.
First thing to do would be to try to remove css file one by one from your project to spot which one as the issue. If you can't find it, then it comes from a dependency, and you best bet would be to remove empty-rules
rule from CSSLint or from the linter you are using.
Resource: https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules
Upvotes: 1