question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find modules

See original GitHub issue

Bug Report

Overview

I get the error, TypeError: WebAssembly Instantiation: Import #0 module="utils" error: module is not an object or function. I assume there is something I need to do to make these available, but I could not find anything in the docs.

Expected

Should import modules like log from the env module, as shown in the simple Walt Explorer examples and quick start guide.

Actual

TypeError - can’t resolve modules.

Example

Versions

Node.js: v8.10 Webpack: 4.15.1 walt-loader: 1.0.21

import { log: LogType } from 'env'; // also tried 'console' here
type LogType = (i32) => void;

Webpack config:

const path = require('path')

module.exports = {
  resolve: {
    extensions: [".walt", ".js", ".css"]
  },
  module: {
    rules: [
      { test: /\.walt$/, use: 'walt-loader' },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: "babel-loader"
      },
      { test: /\.css$/, use: ['style-loader', 'css-loader'] }
    ]
  },
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ballercatcommented, Jul 6, 2018

It still runs int the JavaScript sandbox, think of it as if you linked a .dll into your executable. You can call the methods imported but you don’t change how they are written/executed.

There is even a slight penalty for crossing that wasm <> js boundary (in either direction) as the engine has to perform validation and security(?) checks. I think Firefox at least has worked around some of these speed bumps though.

0reactions
njtrettelcommented, Jul 6, 2018

@ballercat didn’t want to open a new issue for this, because it’s just a random question. a response is not urgent.

if i were to import a javascript library to use in walt (such as importing console.log in your example), would the performance be the same as if i ran it in JS? i.e, these imported JS library are still run in a JS environment right? I would assume so.

thinking wishfully - It would be super cool if I could import something like lodash and have it perform like WASM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
This happens when a first npm install has crashed for some reason (SIGINT of npm), or that the delay was too long, or...
Read more >
Error: cannot find module [Node npm Error Solved]
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
Read more >
How to resolve "Cannot find module" error in Node
The Cannot find module error is a common error that usually happens when dependencies are not installed. Once you install your dependencies and ......
Read more >
How to resolve can't find module error in Node.js
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's ......
Read more >
Cannot find module 'X' error in Node.js
To solve the "Cannot find module" error in Node.js, make sure to install the package from the error message if it's a third-party...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found