This is not a general not defined error, I've been trying to debug it for the past two hours.
I am defining a value in webpack plugins (for a global variable) for API endpoint and trying to access it in the application gives a weird error. So here is the plugins structure in webpack.dev.js (which merges into webpack.config.js).
new DefinePlugin({
'ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR,
// ... some other lines
'API_PARENT': "DEV_PARENT_TEST" // this is the line in question
})
in custom-typings.d.ts I have declared it to avoid ts erros
declare var API_PARENT: string;
Now in one of my app components when I try console.log(API_PARENT) I get the mysterious error bellow
EXCEPTION: Uncaught (in promise): ReferenceError: DEV_PARENT_TEST is not defined
ReferenceError: DEV_PARENT_TEST is not defined
The stack trace leads to that log line. The part I don't get is that why this is throwing up in the first place. the DEV_PARENT_TEST is a value not even a key why is there a reference error on it!