Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work when running from node #24

Open
Ketchup901 opened this issue Nov 23, 2019 · 0 comments
Open

Does not work when running from node #24

Ketchup901 opened this issue Nov 23, 2019 · 0 comments

Comments

@Ketchup901
Copy link

Ketchup901 commented Nov 23, 2019

In the readme, you have given this example:

const { Client } = require('libquassel');
const net = require('net');

const socket = net.createConnection({
  host: "localhost",
  port: 4242
});

const quassel = new Client((next) => next("user", "password"));

quassel.on('network.init', (networkId) => {
    network = quassel.networks.get(networkId);
    // ...
});

// ...

quassel.connect(socket);

However, when you run this example using node foo.js, there is an error saying:

import './usertypes'; // register usertypes first
^^^^^^

SyntaxError: Cannot use import statement outside a module

If you change const { Client } = require('libquassel'); to const { Client } = require('libquassel/dist/libquassel');, the error is:

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.libquassel=t():e.libquassel=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=functi

ReferenceError: window is not defined

If you add global.window = {}; to the beginning of the file, the script seems to run, but it closes after a tenth of a second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant