Npm -g truffle installation problem & visual studio code

Good Afternoon Crypto Community!

  1. Issue
    As you might have come already to the conclusion from the topic name, I have one small problem and I am not really sure how to solve it. The problem is : Any time I try to install -g truffle for the Ethereum Smart Contract Programming 201 course, I get a specific error saying :
    " Legacy version of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)".
    Here is also additional photo : https://prnt.sc/uhsodm

Does anyone have any idea how to fix this issue?

  1. Issue
    In visual studio code I am not sure how to update compiler version but every time I try to create a contract with .sol extension I get a following error :
    “Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version”.
    Photo : https://prnt.sc/uhsp6a

If anyone knows anything that I could do to fix this I would appreciate any feedback!
I will be trying to solve it myself as well, but in any case if someone knows any solution that could help a lot. Thank You Crypto Community! :smiley:

Hi @JanjoHR1,

1. Issue
That looks just a warning to me, it’s common when installing programs.
It seems that you have indeed truffle correctly installed.
Type this command into your PowerShell: truffle --version
It should appear something like this

Schermata 2020-09-16 alle 10.34.21

2. Issue

You have to set the right compiler in truffle-config.js

  • Open the file truffle-config.js
  • Scroll down until you see:
  compilers: {
    solc: {
      //version: "0.7.0",    // Fetch exact version from solc-bin (default: truffle's version)
    }
  }

Uncomment //version: and change it with your current solidity version.
If you are using solidity 0.5.12:

  compilers: {
    solc: {
      version: "0.5.12",    // Fetch exact version from solc-bin (default: truffle's version)
    }
  }

Happy coding,
Dani

1 Like

For the 1st issue ) -Yes it is correct. I get the same like you, thank you … I thought that this was a problem :slight_smile:

For the 2nd issue)- I Find that my compiler version in this folder is 0.5.1… Even when I change this version to 0.5.12; it still gives me the same error as before. Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version”.

// Configure your compilers
  compilers: {
    solc: {
       version: "0.5.12",    // Fetch exact version from solc-bin (default: truffle's version)

Any other idea? xD
But thank you for your help :slight_smile:

@JanjoHR1

What’s the pragma statement in your contracts?
example

pragma solidity ^0.5.0;
1 Like

I was writing it normally as

pragma solidity 0.5.12;

But I tried now your way too, still the same error…

pragma solidity ^0.5.12;

Are you importing any other contract? Somewhere you should have a contract that uses solidity 0.7.

Please create a repo on github and upload the whole project.

1 Like

I started using the following code as the opening lines for the file, it solves the problem for me.

// SPDX-License-Identifier: MIT

pragma solidity >=0.4.22 <0.8.0;

But thank you for your help. :smiley: