Search code examples
javascriptfrontendautobahnwhen-js

How to install library 'When' in Javascript


I have got 2 files: index.html and index.js. I am using them to try and do autobahn communication. Autobahn works, but 'When' doesn't work.

I have used bower to download and install Autobahn, and then manually included autobahn.js from withing the html. I have done the same for When, but an error appears in the When library.

Index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Testing Autobahn</title>
</head>

<body>
<p> Fancy paragraph! </p>

<!--Bower-->
<script src="./bower_components/module/module.js"></script>
<script src="./bower_components/autobahn/autobahn/autobahn.min.js"></script>
<script src="./bower_components/when/when.js"></script>

<!--Node.js-->
<!--<script src="./node_modules/autobahn/lib/autobahn.js"></script>-->

<!--Browserify-->
<!--<script src="./bundle.js"></script>-->

<!--The actual main script file-->
<script type="text/javascript" src="index.js"></script>
</body>
</html>

When I open index.html in a web browser I get the following:

error


Solution

  • Found the answer. The deal was to install the libraries using npm. After that in the node-modules folder there are 2 folders containing the libs: 1) autobahn-browser 2) when

    After including them like this it worked like a charm: