Solidity-docgen gives Syntax Error: Unexpected token 'export'

(prompt)> yarn run solidity-docgen --solc-module <point to solc version 0.7.4 binary>
SyntaxError: Unexpected token ‘export’

:computer: Environment

node v 12.18.3, repros on node 9, 10, 11, 12, 13, 14, 15
“solidity-docgen”: “^0.5.7”,
contracts/ folder with several contracts with “pragma solidity =0.7.4;”
macos 10.15.7

:memo:Details

Looking around at this error generally it has to do with node not supporting ES6 syntax (“export”) and using babel to transpile is a solution, but this seems overly complex, there must be something else going on

:1234: Code to reproduce

2 Likes

Yes this should just work. What are you putting in as argument to --solc-module?

1 Like
sudo yarn run solidity-docgen  --solc-module /Users/br4e/Documents/GitHub/solc-select/bin/solc

(prompt)> /Users/br4e/Documents/GitHub/solc-select/bin/solc --version
solc, the solidity compiler commandline interface
Version: 0.7.4+commit.3f05b770.Linux.g++
1 Like

You’re not supposed to use a solc binary, it should be a path to a JavaScript solc module installed from npm. Take a look at the example in the changelog for version 0.5.6.

1 Like

This is working in my clean test repo, now going to try to get to work in my main repo.

--solc-module=solc-module path to an alternative solc module
^^ this is what --help gives, maybe this could be explained in more depth for future people tripping over it

1 Like

Hi @br4e,

I have created a PR to add Solidity 0.7 instructions to the README: https://github.com/OpenZeppelin/solidity-docgen/pull/252