Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Can't compile contracts due to 'module' is undefined #150

Closed
dgoswami75 opened this issue Apr 30, 2016 · 22 comments
Closed

Can't compile contracts due to 'module' is undefined #150

dgoswami75 opened this issue Apr 30, 2016 · 22 comments

Comments

@dgoswami75
Copy link

dgoswami75 commented Apr 30, 2016

I'm getting an error for 'module' is undefined when I run 'truffle compile' from the project folder.
Any pointers to what might be going wrong? truffle init works fine and creates the project structure as described in the docs.
I'm a newbie to Truffle, so please let me know if I need to provide more info. Attaching the error screenshot
moduleundefined

@dgoswami75
Copy link
Author

Just wanted to check if anyone can help on the above error. I hadn't been able to get to it for the last few days, but will be getting back to it later today... I need some help with the above error.
Thanks a lot for any input.

@webthethird
Copy link

I am having the same issue. Same newbie status. Please help us!

@vmadrienpro
Copy link

Quick tweak :

-Find the file truffle.cmd
-Copy the file and rename it (e.g truf.cmd) (in the same repo )
-use truf compile

@brendan87
Copy link

brendan87 commented Jun 17, 2016

@vmadrien is right - what is happening is the OS is trying to run the truffle.js file when you type truffle compile, instead of running the truffle.cmd link to the node module that (for me) was in C:\Users\xxxx\AppData\Roaming\npm (it should also be on the Windows variable PATH so you can look there to find it too). Go rename that truffle.cmd file and you should be fine. Either that or rename the truffle.js file temporarily before running truffle compile in the project directory.

@tcoulter
Copy link
Contributor

Interesting. As an alternative, you can always try Git for Windows, which provides the Git BASH terminal. It's guaranteed to work correctly there. https://git-for-windows.github.io/

@vmadrienpro
Copy link

I should have explained that tweak more :) Thanks @brendan87

@tcoulter
Copy link
Contributor

This issue has been fixed on the Truffle master branch and will be released later this week (likely tomorrow). The README has been updated in two places that describe how you can avoid this issue in the future. Thanks for reporting!

http://truffle.readthedocs.io/en/latest/getting_started/installation/#recommendations-for-windows
http://truffle.readthedocs.io/en/latest/advanced/configuration/#resolving-naming-conflicts-on-windows

@ariolaclint
Copy link

Hi Guys,

Download the
Cygwin64 Terminal for windows
then run again truffle compile on truffle directory

image

@rts-2
Copy link

rts-2 commented Jul 11, 2017

When I rename the file, then I get the error "Could not find suitable configuration file" - is anyone else having this problem?

@batjko
Copy link

batjko commented Jul 29, 2017

I am having this issue, just following the setup of the pet-shop (http://truffleframework.com/boxes/pet-shop), throwing this error when trying to truffle compile.
I'm on Windows 10 64bit.

@tcoulter If it was fixed, I seem to encounter a regression.
Also, the two links posted back in Aug last year are dead now.

I can go and manually rename the truffle.js as suggested, but it would be nice if that weren't necessary.

@batjko
Copy link

batjko commented Jul 29, 2017

Ah, never mind. Found this in the current documentation:
http://truffleframework.com/docs/advanced/configuration#resolving-naming-conflicts-on-windows

@yuandi0823
Copy link

WIN10 use PowerShell is OK

@masonbrothers
Copy link

masonbrothers commented Sep 29, 2017

If you have the same issue on Windows, instead of truffle compile try truffle.cmd compile

@edu-san
Copy link

edu-san commented Nov 21, 2017

not sure if this get resolved but you can always use truffle.cmd compile

@bitsabhi
Copy link

Either use truffle.cmd compile or go to the /contract directory and use truffle compile .

@npittsley
Copy link

Yep, using
truffle.cmd compile
worked for me!

@rishikeshjadhav
Copy link

Using truffle.cmd worked for me :)
While reading below helped as well
http://truffleframework.com/docs/advanced/configuration#resolving-naming-conflicts-on-windows

@reddysuresh78
Copy link

I had same problem on windows. But running it from inside the contracts folder worked without any issue.

@Shuooang
Copy link

in windows try ...
'truffle.cmd'
instead of 'truffle'.

Because of PATH_EXT= .......... .JS
truffle.js is excuted.

Or remove '.JS' in PATH_EXT .

@haghighatcs
Copy link

I'm getting an error for 'module' is undefined when I run 'truffle compile' from the project folder.
Any pointers to what might be going wrong? truffle init works fine and creates the project structure as described in the docs.
I'm a newbie to Truffle, so please let me know if I need to provide more info. Attaching the error screenshot
moduleundefined

This is an OS Conflict that may happen in some windows operation systems.
because windows wants to run truffle.js file instead of truffle.cmd.
you can simple solve this problem by using truffle-config.js file to keep the configuration (instead of truffle.js).
do not rename truffle.cmd and do not bring headache for yourself.
it's very simple. "keep the configurations in truffle-config.js file".

@rahultelgote1989
Copy link

This could be issue with Windows Command Prompt; you can try with Windows Powershell, it worked like a charm for me:
image

@RudrikaFichadiya7
Copy link

RudrikaFichadiya7 commented Nov 7, 2020

Interesting. As an alternative, you can always try Git for Windows, which provides the Git BASH terminal. It's guaranteed to work correctly there. https://git-for-windows.github.io/

Thank you It helped me! for compiling but still get error while migrating.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests