If using a recent web3 (e.g. 1.0.0-beta.50), a possible remedy is to set esModuleInterop:
See also: https://github.com/ethereum-ts/TypeChain/blob/5b4f397c64b7d32cdf2ce50062f69bad324efa99/test/integration/targets/web3-1.0.0/
I am expecting that you already executed npm init at first.
I assume you are using windows? I always develop blockchain related stuff on Ubuntu.
Here is what you need to do on windows to set it up properly.
Step 1: npm install -g --production windows-build-tools
Step 2: npm install -g node-gyp
Now it should work!
If you still have a problem make sure ...
Your version of Python does not match the required version for one of the dependencies. To explain your error in more detail, Python is not compiled, so version mismatch is found at run-time. The program is using the old Python 2.7 print syntax which is flagging the error. By installing the appropriate version of Python 2.7 or upgrading to a version of the ...
There is an alternative method. You can download ganache from the below link
After it has downloaded execute the below command in terminal
$sudo chmod a+x ganache-1.2.2-x86_64.AppImage
Now search for ganache and double click on it and press yes ...
I guess it is not compatible with node 12.x
I managed to install it with node 10.16.0
I also had to install the following to solve some error messages:
sudo apt-get install libgconf-2-4
sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
uninstall / reinstall node (deleted all related folders in local directories too, including in Roaming)
in POWERSHELL as Administrator: npm install --global --production windows-build-tools
npm install --save --no-optional web3.
Hope this works for you.
Not sure (because you didn't provide full error logs), but I think the problem is with some build-tools, installing it will solve your problem.
npm install -g windows-build-tools
Note: Make sure that you install windows-build-tools globally.