Node: Node 14 with warning (node:31518) Warning: Accessing non-existent property 'column' of module exports inside circular dependency

Created on 22 Apr 2020  路  22Comments  路  Source: nodejs/node

  • Version: Node.js 14.0
  • Platform: mac 10.15.3
  • Subsystem:

Happens in lots of library I use.

What steps will reproduce the bug?

Repo:
https://github.com/gengjiawen/sample
CI:
https://github.com/gengjiawen/sample/runs/607139469?check_suite_focus=true#step:4:113

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

no warning

What do you see instead?

(node:32751) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:32751) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:32751) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:32751) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:32751) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

Additional information

cc @nodejs/modules-active-members

module

Most helpful comment

@addaleax Can this warning be more friendly, like telling me which module cause the problem.

All 22 comments

After I updated my deps, vue project looks fixe.
But looks still exist like in https://github.com/jessety/pm2-installer/issues/3

because this pr only landed in node.js v14.0.0

this must be a SEMVER-MAJOR but not in the update docs

cc @nodejs/releasers

@addaleax Can this warning be more friendly, like telling me which module cause the problem.

@gengjiawen we do have the way to display which module cause the problem

use --trace-warnings, not friendly for the user, the many unnecessary stacks

>node --trace-warnings a
(node:19168) Warning: Accessing non-existent property 'foo' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:814:11)
    at Object.get (internal/modules/cjs/loader.js:825:5)
    at Object.<anonymous> (C:\Users\Himself65\Desktop\github\test\cycle\c.js:4:10)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Module.load (internal/modules/cjs/loader.js:1034:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)
    at Module.require (internal/modules/cjs/loader.js:1074:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\Himself65\Desktop\github\test\cycle\b.js:1:1)

another problem is that we not telling this in the v14 docs.

For anyone run into similar issue, npx cross-env NODE_OPTIONS="--trace-warnings" yarn build this may help you.

Right, I鈥檓 surprised that https://github.com/nodejs/node/pull/32797 was not released in 14.0.0. I assumed that it would be, as it was on v14.x-staging before the release. It should be included in the next one, though. /cc @BethGriggs

Right, I鈥檓 surprised that #32797 was not released in 14.0.0. I assumed that it would be, as it was on v14.x-staging before the release. It should be included in the next one, though. /cc @BethGriggs

It was included (via https://github.com/nodejs/node/commit/1092bb94f47b25b626827a067986f1b428561f58): https://github.com/nodejs/node/commits/v14.0.0?after=73aa21658dfa6a22c06451d080152b32b1f98dbe+42

Right, I鈥檓 surprised that #32797 was not released in 14.0.0. I assumed that it would be, as it was on v14.x-staging before the release. It should be included in the next one, though. /cc @BethGriggs

It's included in release too. Full console log include this (the log is very long, I am not noticed it in first place, thanks @Himself65 pointed out).

Maybe joining this (Use 'node --trace-warnings ...' to show where the warning was created) with first warning to make the logic connection more strong ?

(node:2658) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2658) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency

I guess there might be a bug in #32797 then, it is supposed to show the hint after the first warning

I think this is the line ?

image

In issue description the log is not complete, you need to click the CI link.

why --trace-warnings not enable by default?

This is a lame glitch out of the blue, without any immediate hints. Has to be addressed somehow.

why --trace-warnings not enable by default?

@addaleax I think this is reasonable, what do you think ?

@gengjiawen I don鈥檛 have a strong opinion about that. If you think it鈥檚 a reasonable change, feel free to open a PR, I guess? :)

so, what to do?

@fuchunhui - It depends on where the warnings are coming from.

Step 1

Run Node with the --trace-warnings flag. Check the stacktrace for hints of packages you're using.

Step 2

Once you identify a package, check if the error has been fixed upstream.

For me it was shelljs (as explained here: https://github.com/shelljs/shelljs/commit/05374a749992969bb6b853095f4c9308df69aa82 / https://github.com/shelljs/shelljs/pull/973). After updating shelljs to 0.8.4 I no longer see the warnings.

As @gengjiawen stated:

For anyone run into similar issue, npx cross-env NODE_OPTIONS="--trace-warnings" yarn build this may help you.

I will open a new issue if I can figure out where such an issue belongs - this doesn't seem to belong in the API docs per say as it is not the Node API, but the fact that 30 odd people have given the quoted post a thumbs up suggests to me that I wasn't the only one wondering how I pass a NodeJS --trace-warnings flag when the warning was seen after running a script via a package manager.

ideally
1) this is placed in some docs somewhere in a format which is more generic, e.g. npx cross-env NODE_OPTIONS="--trace-warnings" [your package manager] [your script name]
2) A link to this documentation is placed in the output - i.e. something like use Node --trace-warnings... see https://nodejs/docs/tracewarnings.

Any idea where such documentation might belong?

Have similar issue and just do npm update and it work fine.

Have similar issue and just do npm update and it work fine.

yes it worked for me too.

For me, this solved my problem:

yarn remove mongoose
yarn add mongoose

@fuchunhui - It depends on where the warnings are coming from.

Step 1

Run Node with the --trace-warnings flag. Check the stacktrace for hints of packages you're using.

Step 2

Once you identify a package, check if the error has been fixed upstream.

For me it was shelljs (as explained here: shelljs/shelljs@05374a7 / shelljs/shelljs#973). After updating shelljs to 0.8.4 I no longer see the warnings.

This cleared up the majority of the warnings for me.

You should update lock file:

yarn upgrade or npm update

Was this page helpful?
0 / 5 - 0 ratings