0

I have a following code and get "TypeError: Error resolving module specifier: solc/wrapper" error. I followed these instructions https://github.com/ethereum/solc-js#browser-usage to put the code together.

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="https://solc-bin.ethereum.org/bin/list.js"></script>
	<script type="text/javascript" src="https://solc-bin.ethereum.org/bin/soljson-v0.5.1+commit.c8a2cb62.js"></script>
        <script type="module" defer>
          import * as wrapper from 'solc/wrapper';
        </script>
    </head>
    <body>
    </body>
</html>

Please any suggestions where is the problem? Thank you.

4
  • Does solc/wrapper exist relative to the current path? I imagine that the filename ends with .js which is required when using es6 modules in browsers. Commented Dec 14, 2018 at 18:59
  • @Evert It does not exist. I thought it will be imported from the libraries declared above the import statement. Commented Dec 14, 2018 at 19:06
  • @user3024710 Despite what the documentation you read seems to imply, I'm 90% sure that's not a thing. Commented Dec 14, 2018 at 19:19
  • @user3024710 yea that's not how import works. import references an actual file. Commented Dec 14, 2018 at 19:32

2 Answers 2

1

I don't know what the problem was, since I've never seen that ES6 import syntax before, but I fixed it by specifying exactly where to import from:

<!DOCTYPE html>
<html>
    <head>
        <script type="module" defer>
          // debugging
          document.getElementById("runninate").addEventListener("click", function(e){var code=document.getElementById('miniconsole').value; console.log('> ' + code); console.log(eval(code))})

          import * as wrapper from 'https://ethereum.github.io/solc-bin/bin/soljson-v0.5.0-nightly.2018.10.15+commit.b965fd6e.js';
          const solc = wrapper(window.Module);
        </script>
    </head>
    <body>
        <input id="miniconsole" />
        <button id="runninate">Runninate!</button>
    </body>
</html>

I'm not confident enough to say that the syntax was wrong, but considering that they had a typo in the Node.JS example I doubt they tested this.

Note that this fails to import properly because the thing that's being imported doesn't quite work.

Sign up to request clarification or add additional context in comments.

10 Comments

Weird, when I try your code, it says "TypeError: wrapper is not a function". Does the code work for you?
@user3024710 Yeah... What type is wrapper for you?
@user3024710 Try the require() syntax to see if that makes any difference.
@JossClassey That just errored completely, saying that require wasn't a thing.
@user3024710 Did you try it with soljson-latest.js?
|
0

I have to install solc npm package

npm install solc

in order to make the code running.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.