以太坊Truffle,在 truffle init 和 truffle compile 出現:運行時錯誤,“module”未定義

在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.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章