Skip to content
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

Uncaught ReferenceError: node_env_var_name is not defined #628

Comments

@hcharley
Copy link

hcharley commented Dec 1, 2020

What is the current behavior?

I am currently seeing this bug in 3.3.3 in the browser:

Uncaught ReferenceError: node_env_var_name is not defined
    at j._.loadFileConfigs

Screen Shot 2020-11-30 at 8 19 37 PM

It appears it is from this commit:

b4ba63c

In this line:

b4ba63c#diff-d5109920b34c2b2e141bd41232d8876432a17479c388e142d8a036bb7b36ea62R520

What is the expected behavior?

Previous versions of node-config would not throw this error.

Please tell us about your environment:

  • node-config version: 3.3.3
  • node-version: 12.18.3

Other information

Webpack config:

const webpack = require('webpack');
const config = require('config');

const getNodeConfigPlugin = (addPlugin) => {
  const CLIENT_CONFIG = {
    app: {
      gitSha: config.get('app.gitSha'),
    },
    env: {
      nodeEnv: config.get('env.nodeEnv'),
    },
    performance: config.get('performance'),
  };

  console.warn(
    CLIENT_CONFIG,
    'WARNING: THIS CONFIGURATION INFORMATION WILL BE AVAILABLE TO THE CLIENT'
  );

  addPlugin(
    new webpack.DefinePlugin({
      'process.env.NODE_CONFIG': JSON.stringify(JSON.stringify(CLIENT_CONFIG)),
    })
  );
};
exports.getNodeConfigPlugin = getNodeConfigPlugin;
@benkiefer
Copy link

benkiefer commented Dec 3, 2020

The line causing this is line 520 of config.js. It appears to have been broken by #576.

@benkiefer
Copy link

We are seeing it in server side code as well.

 ReferenceError: node_env_var_name is not defined
 at Config.loadFileConfigs (node_modules/config/lib/config.js:520:8)
      at new Config (node_modules/config/lib/config.js:116:27)
      at Object.<anonymous> (node_modules/config/lib/config.js:1459:31)

@hacknlove
Copy link

this
for (node_env_var_name of node_env_var_names) {

Should be for (const node_env_var_name of node_env_var_names) {

@tapsboy
Copy link

tapsboy commented Feb 11, 2021

For anyone like us, we found the issue occurring where we are using babel to transpile code. In other node apps, where we dont use babel, it doesn't throw any error

lorenwest added a commit that referenced this issue Mar 5, 2021
Fix #628: node_env_var_name is not defined
@lorenwest
Copy link
Collaborator

Pushed in v3.3.5 today. Thank you for the patch!

samueljseay added a commit to woocommerce/woocommerce-blocks that referenced this issue Sep 4, 2023
samueljseay added a commit to woocommerce/woocommerce-blocks that referenced this issue Sep 4, 2023
samueljseay added a commit to woocommerce/woocommerce-blocks that referenced this issue Sep 4, 2023
samueljseay added a commit to woocommerce/woocommerce-blocks that referenced this issue Sep 5, 2023
* Fix bug where is-plain-obj is not transpiled by Jest, update lock.
* Update packages.
* Mock useSelect for a handful of RichText selectors in test.
* Resolve react to single version to avoid invalid hook errors.
* Patch trim-html locally to avoid a bug in the released npm source.
* Mock out resizeObserver to avoid FezVrasta/react-resize-aware#58
* Don't transpile config package: node-config/node-config#628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment