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.

truffle exec does not handle require statements properly

See original GitHub issue

Summary: truffle exec <example_script> does not properly handle require statements for local node modules in example_script.

Details: truffle exec uses the function at https://github.com/ConsenSys/truffle/blob/master/lib/require.js#L38 to handle require statements. However, if a local module is required, the line at https://github.com/ConsenSys/truffle/blob/master/lib/require.js#L53 assumes that the node_modules directory is present in the same directory as the script being executed, rather than searching upward for the root of the node package before looking for node_modules.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
360disruptcommented, Sep 8, 2018

@mathcrypto maybe this helps: https://github.com/trufflesuite/truffle/issues/676 Is your script wrapped into module.exports

Read more comments on GitHub >

github_iconTop Results From Across the Web

Truffle - a proper way to execute a chunk of code
Let's say I have a complex operation to execute, for example deploying 6 contracts and calling functions to each one, passing addreses to...
Read more >
Proper use of artifacts.require? - Stack Overflow
From this I infer that the globally scoped artifacts with its method require are automatically defined by the truffle executable tool when doing ......
Read more >
ConsenSys/truffle - Gitter
I'm having an issue using the @truffle/config npm package. It appears that it depends on @truffle/events , which uses the ora package but...
Read more >
Write Solidity tests - Truffle Suite
You can easily test if your contract should or shouldn't raise an exception (i.e., for require() / assert() / revert() statements; throw on...
Read more >
Truffle documentation - Read the Docs
This file comes with every Truffle project, and is usually not edited. ... To use only ContractTwo, your artifacts.require() statement would ...
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