# Compiling OpenZeppelin Contracts in VSCode using solc

**URL:** <https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594>\
**Category:** Contracts\
**Created:** [January 29, 2021, 1:02pm UTC](https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594 "2021-01-29T13:02:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien\_Lobster](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/alien_lobster/32/4179_2.png) [@Alien\_Lobster](https://forum.openzeppelin.com/u/Alien_Lobster)\
**Post date:** [January 29, 2021, 1:02pm UTC](https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594/1 "2021-01-29T13:02:45Z")

</div>

I’m trying to create compile a contract on vscode using some openzeppelin contracts I installed through npm and it keeps throwing a parser error

**💻 Environment**  
Ubuntu  
pragma solidity ^0.4.0;  
“@openzeppelin/contracts”: “^3.3.0”  
“solc”: “^0.4.25”,

**📝Details**  
Whenever I try to compile I get this error:

```
[ ':3:1: ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not supplied initially.\nimport "@openzeppelin/contracts/token/ERC20/ERC20.sol";\n^-----------------------------------------------------^\n',
     ':4:1: ParserError: Source "@openzeppelin/contracts/math/SafeMath.sol" not found: File not supplied initially.\nimport "@openzeppelin/contracts/math/SafeMath.sol";\n^-------------------------------------------------^\n' ]
```

---

<div class="post-metadata">

**Author:** ![Amxx](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/amxx/32/668_2.png) [@Amxx](https://forum.openzeppelin.com/u/Amxx)\
**Post date:** [January 29, 2021, 1:26pm UTC](https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594/2 "2021-01-29T13:26:34Z")

</div>

I am not familiar with vscode, but this looks like the solc compiler is not configured to look in the right place. If you imported OpenZeppelin contracts using npm, you should make sure that solc is called with the necessary flag to resolve files under `node_modules`

Additionnaly, I’d like to point out that `@openzeppelin/contracts` requiers solc ^0.6.0. Version 0.4.x of solidity has been deprecated for a long time, and suffers from many bugs. I very strongly encourage you to move to solidity 0.6 of above:

- 0.6.x is supported by `@openzeppelin/contracts”: “^3.3.0`
- 0.7.x is supported by `@openzeppelin/contracts”: “^3.3.0-solc-0.7`
- 0.8.x support is comming very soon !

---

<div class="post-metadata">

**Author:** ![Alien\_Lobster](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/alien_lobster/32/4179_2.png) [@Alien\_Lobster](https://forum.openzeppelin.com/u/Alien_Lobster)\
**Post date:** [January 29, 2021, 1:52pm UTC](https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594/3 "2021-01-29T13:52:59Z")

</div>

Thanks. Updating my modules fixed the parser error issue.

But now I get this error:

```
AssertionError [ERR_ASSERTION]: Invalid callback object specified

```

From what I’ve read the way you compile a contract with new versions of solc has changed.

Here’s my old compile code:  
const path = require(‘path’);  
const fs = require(‘fs-extra’);  
const solc = require(‘solc’);

```
const buildPath = path.resolve(__dirname, 'build');

fs.removeSync(buildPath);

const tokenSalePath = path.resolve(__dirname, 'contracts', 'SMPTokenSale.sol');
const source = fs.readFileSync(tokenSalePath, 'utf-8');

const output = solc.compile(source, 1);

console.log(output);

fs.ensureDirSync(buildPath);

for( let contract in output){
    fs.outputJSONSync(
        path.resolve(buildPath, contract.replace(':', '') + '.json'),

        output[contract]
    );
}

```

How do I format this for the new version, if that’s the cause of the Assertion error?

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [February 1, 2021, 2:43am UTC](https://forum.openzeppelin.com/t/compiling-openzeppelin-contracts-in-vscode-using-solc/5594/4 "2021-02-01T02:43:57Z")

</div>

Hi @Alien_Lobster,

You may want to look at using either Hardhat or Truffle to develop, test and deploy your smart contracts.  
See the OpenZeppelin Learn guides:  
[https://docs.openzeppelin.com/learn/developing-smart-contracts#setting-up-a-solidity-project](https://docs.openzeppelin.com/learn/developing-smart-contracts#setting-up-a-solidity-project)
