PaulRBerg / hardhat-template

Hardhat-based template for developing Solidity smart contracts
MIT License
1.96k stars 559 forks source link

Node v14+ Warning: Accessing non-existent property 'VERSION' #28

Closed briankostar closed 3 years ago

briankostar commented 3 years ago

When running the scripts defined in package json (eg. yarn clean), keep running into this warning:

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

PaulRBerg commented 3 years ago

Hey Brian! I just ran the yarn clean script and it works fine on my end:

Capture d’écran 2021-03-24 à 23 32 34

Could you share the following information so I can investigate, please?

kraikov commented 3 years ago

I have the same issue:

briankostar commented 3 years ago

Hey Paul, yup this is my env:

PaulRBerg commented 3 years ago

Thanks for the extra info, guys! Looks like an issue with node v14 specifically.

briankostar commented 3 years ago

I've also tried on node 14.16.0 and 15.12.0 but still same issue.

PaulRBerg commented 3 years ago

That is, node v14 and above. There must be a new behaviour that doesn't work well with my Hardhat clean task.

PaulRBerg commented 3 years ago

Looks like this is an upstream problem. Running NODE_OPTIONS="--trace-warnings" yarn run test gave me this:

(node:14555) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:698:11)
    at Object.get (node:internal/modules/cjs/loader:712:5)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/prettier-plugin-solidity/node_modules/antlr4/tree/Trees.js:13:49)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/prettier-plugin-solidity/node_modules/antlr4/RuleContext.js:122:13)

Looks like prettier-plugin-solidity needs to patch their dependencies. I opened an issue there: https://github.com/prettier-solidity/prettier-plugin-solidity/issues/463

The good news is that the warning can be safely ignored. The bad news is that until prettier-plugin-solidity patches this, the warning will still be around in node v14 and above.

PaulRBerg commented 3 years ago

Update: prettier-plugin-solidity is patched, but solidity-coverage has the same problem. Will open an issue in their repo too!

(node:97946) Warning: Accessing non-existent property 'VERSION' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:698:11)
    at Object.get (node:internal/modules/cjs/loader:712:5)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/sc-istanbul/lib/command/help.js:9:37)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at /Users/paulrberg/workspace/templates/solidity-template/node_modules/sc-istanbul/lib/util/factory.js:56:35
(node:97946) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:698:11)
    at Object.get (node:internal/modules/cjs/loader:712:5)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/solidity-coverage/node_modules/@solidity-parser/parser/dist/antlr4/RuleContext.js:32:46)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/solidity-coverage/node_modules/@solidity-parser/parser/dist/antlr4/PredictionContext.js:10:19)
(node:97946) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:698:11)
    at Object.get (node:internal/modules/cjs/loader:712:5)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/solidity-coverage/node_modules/@solidity-parser/parser/dist/antlr4/tree/Trees.js:15:49)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/paulrberg/workspace/templates/solidity-template/node_modules/solidity-coverage/node_modules/@solidity-parser/parser/dist/antlr4/RuleContext.js:126:13)
PaulRBerg commented 3 years ago

See https://github.com/sc-forks/solidity-coverage/issues/607#issuecomment-817586788.

PaulRBerg commented 3 years ago

The warning should be gone now, since commit 8244999. Thanks for the help with identifying this issue, @briankostar and @kraikov!

briankostar commented 3 years ago

Awesome! I can confirm the fix. Specifically, it was the sc-istanbul 0.4.5 sub package that was the issue for me. After its upgraded to 0.4.6, warnings disappeared. Thanks for your amazing effort.