question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'env' of undefined

See original GitHub issue

I am unable to start my app unless I failed to follow instructions. The error is: context.env === "production" ? sassRule.loader : sassRule.use;

package.json:

  "dependencies": {
    "@craco/craco": "^2.4.0",
    "antd": "^3.11.0",
    "craco-antd": "^1.5.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-scripts": "^2.1.1"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test"
  },

craco.config.js

const CracoAntDesignPlugin = require("craco-antd");

module.exports = {
  plugins: [{ plugin: CracoAntDesignPlugin }]
};

Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
thomasflcommented, Jul 5, 2019

When running running craco start with NODE_ENV set to production, the process prints out this exception. The problem was actually me trying to run craco in production mode. You should not run craco in production, you should run craco build. My suggestion is that craco exits with a polite error message telling you not to run craco in production mode.

$ NODE_ENV=production npm start

> sosialhjelp-innsyn@0.1.0 start /Users/thomasfl/workspace/sosialhjelp-innsyn
> craco start

/Users/thomasfl/workspace/sosialhjelp-innsyn/node_modules/@craco/craco/lib/plugin-utils.js:29
    throw new Error(
    ^

Error: Found an unhandled loader in the production webpack config: /Users/thomasfl/workspace/sosialhjelp-innsyn/node_modules/style-loader/index.js

1reaction
ndbroadbentcommented, Dec 9, 2018

Awesome, and thanks for the tip! I didn’t realize Travis CI supported Windows now, so that’s awesome! I’ll try to get the tests running on Windows as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'env' of undefined - JavaScript
This is my app.js page code its working fine but when i click test completed button its not completed var express = require("express");...
Read more >
Vue cli - TypeError: Cannot read property 'env' of undefined
Try to define it as a computed property using require function : computed:{ background(){ return require("`${process.env.
Read more >
Cannot read property 'env' of undefined · Issue #1277 - GitHub
this a bug report Parcel produced an error but builds the packages just fine. Configuration (.babelrc, package.json, cli command) ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError: Cannot read property 'env' of undefined
HTML : Uncaught TypeError: Cannot read property ' env' of undefined [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found