ReferenceError: WebAssembly is not defined - node.js

I'm using ttest nodejs module in application. Due to updates to it I tried to use updated version ttest#2.0.0. When module start compute data the error appears:
ReferenceError: WebAssembly is not defined
The NodeJS version - 6.9.1.
Error appears in next place:
class CephesWrapper {
constructor(sync) {
// Initialize the runtime's memory
this._wasmMemory = new WebAssembly.Memory({
'initial': TOTAL_MEMORY / WASM_PAGE_SIZE,
'maximum': TOTAL_MEMORY / WASM_PAGE_SIZE
});
.....
}
}
Is there any advices about solving this issue? Is it possible to define WebAssembly?

The WebAssembly support is added in NodeJs 8.0.0. Update your NodeJS to make it work.

In my case, the problem was that I was running my browser in safe mode (Mozilla Firefox).
Simply shutdown your browser completely and restart. This will quit safe mode (If stuck in safe mode, see here)
For reference, I had found this solution here : https://github.com/mozilla-iot/gateway/issues/2047

Even my node version was 12, and npm version was 6. I was getting the reference error for webassembly.
So I updated the node with latest version(16), it changed the npm version also. Now the reference issue is fixed.
D:\ReactJS\react_demo>node -v
v16.14.0
D:\ReactJS\react_demo>npm -v
8.3.1

Related

Compatibility issues Node and Strapi4

allow me to walk you through some problems I'm encountering when setting up Gatsby with Strapi. Hopefully, somebody can provide me with a solution. Whenever I use the following command yarn create strapi-starter strapi-test gatsby-blog I get the following error:
So what I do next is switching to node v15 using nvm to make strapi compatible with node. The result being that some packages are being installed followed by yet another compatibility error:
Therefore, I am wondering what I am doing wrong and how to make strapi4 compatible with node without having the errors above?
Use Node.js v16 rather than v15. It should fix the issue.
Besides, it's better to use even-numbered version of Node.js, as they're LTS.

How to fix 'ERROR ON PAGE: ReferenceError: Can't find variable: require' - NodeJS with Sinon.js

I have problem with test cases running. actually I upgrade node dependency from old version to new version also node version v6 to v10, Before update npm module my code was working fine. But I do not known what issue happen now.
Please help me out that..!

dyld: Symbol not found: _napi_module_register

Had my node working with the VS Code debugger last night no problem. I haven't touched anything besides install the npm mysql package.
I come back tonight and its throwing this error:
Debugger listening on [::]:49952
dyld: lazy symbol binding failed: Symbol not found: _napi_module_register
Referenced from: /Users/adamsawyers/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
dyld: Symbol not found: _napi_module_register
Referenced from: /Users/myusername/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
Apparently my installation of n (a node version handling package in npm) is busted somehow. My research told me that napi_module_register is part of the n package, but I'm not sure how this got messed up especially since I had it working last night.
I tried reinstalling my node packages, reinstalling n, rebuilding the project file structure, even restarting my computer. Nothing has worked so far.
Any suggestions?
Apparently VS code doesn't like v6.10.3 of nodejs which I am running to create lambda functions in AWS (that is the version specified by AWS)
I use the N package to manage my node version. After switching to the latest version 10.7.0 as of 07/25/2018 (command: sudo n latest) and rerunning the debugger in VS code, it worked perfectly
I'm still unsure as the the cause, but hopefully others find this solution helpful
This exact error happened to me because:
I needed socket.io to run on Node
Which in turn needs ws (websockets on Node)
Also, I needed to run this on an outdated Node version (Node 7) for a very good reason (believe me, I would not want to do this if I wouldn't have to)
However, trying to use it on that old version causes above error message.
Solution
This is a terrible solution, but at least I got it to work.
After some researching, I found no good solution to this. However, a close look at the source code shows that there is a fallback.js next to index.js which implements the same functionality as the native build but without needing a build. This will probably slow things down significantly, but at least it works:
yarn add module-alias
prefix your actual code with this (e.g. via node -r fallbacks.js):
// fallbacks.js
const moduleAlias = require('module-alias');
const dependencyRoot = getDependencyRoot(); // whatever is your root folder, maybe __dirname + '..'
moduleAlias.addAlias('bufferutil', dependencyRoot + '/node_modules/bufferutil/fallback.js');
moduleAlias.addAlias('utf-8-validate', dependencyRoot + '/node_modules/utf-8-validate/fallback.js');
// run actual code here...
PS: In my case, in order to allow ws to run on Node 7, I also had to babel it, since its using modern synytax.

Error: Module version mismatch. Expected 47, got 48

I'm writing a Visual Studio Code extension which uses a native node.js module. When I try to debug this extension in vscode I get the error message from above, when loading the native module (when commenting out the require() call no error comes up). It tried quite a few steps to overcome + test this:
npm uninstall native-module followed by a npm install native-module --save-dev in my vscode extension folder, this compiled the native module completely and without problems.
Completely cleaned my node_modules folder in the extension and did again the npm install --save-dev.
Installed node.js again, both LTS and current. With LTS the error message changes to: expected 47, got 46.
Installed latest vscode (August recovery build)
Launched a node session in my vscode extension folder and loaded my native module. This works nicely.
Read the various questions and comments here on SO. They mostly recommend what I described above.
Still, I cannot get vscode to accept my native module. What can I do? From the above steps it appears as if vscode has been built with a node.js version between current and LTS. Can I force my native module somehow to use a specific version?
Btw. what do those numbers 48, 47, 46 etc. actually mean? The node.js version is of course in the typical form: major.minor.build and nothing of that matches the above version numbers.
Update:
ok, I found what those numbers mean: https://nodejs.org/en/download/releases/
Once you know what those numbers in the error message mean it's easy to solve the issue. Simply install the node.js version that is expected. In my case it's node.js 5.12.0.
Remove node_modules folder
Run npm update
Then;
Run npm install

sails js running testProjects issue in ubuntu

I am new to nodejs and after installing sails when i try to run it, using command sails lift, it gives me below error. Need help to resolve it.
/usr/lib/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:692
function runInContext(context) {
^
illegal access
It was an issue with the version of node i was using v0.11.13. I have changed the version and it started working.

Resources