以太坊Truffle,在 truffle init 和 truffle compile 出现:运行时错误,“module”未定义

  • Post author:
  • Post category:其他



在Windows,cmd环境下使用truffle时有时会出现


运行时错误,”module” 未定义


参见官方文档后,只需调用时写truffle.cmd即可


详见原文:


RESOLVING NAMING CONFLICTS ON WINDOWS

When using the Command Prompt on Windows, the default configuration file name can cause a conflict with the truffle executable, and so you may not be able to run Truffle commands properly on existing projects.

This is because of the way that command precedence works on the Command Prompt. The truffle.cmd executable is on the path as part of the npm package, but the truffle.js configuration file is in the actual directory where the truffle command is run. Because .js is an acceptable executable extension by default, truffle.js takes precedence over truffle.cmd, causing unexpected results.

Any of the following solutions will remedy this issue:

Call the executable file explicitly using its .cmd extension (truffle.cmd compile)

Edit the system PATHEXT environment variable and remove .JS; from the list of executable extensions

Rename truffle.js to something else (truffle-config.js)

Use Windows PowerShell or Git BASH, as these shells do not have this conflict.



版权声明:本文为cyr20040123原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。