Neither "import" nor "require" works

226 Views Asked by At

I'm using Noty version 3 https://github.com/needim/noty. According to the documentation I should use require or import.

import Noty from 'noty';

new Noty({
    text: 'Notification text'
}).show();

// or

const Noty = require('noty');

new Noty({
    text: 'Notification text'
}).show();

But none works. Even in the last version of Chrome.

When I'm using require:

Uncaught ReferenceError: require is not defined

And when import:

Uncaught SyntaxError: Unexpected token import

1

There are 1 best solutions below

0
On

First, I don't agree with giving thumbs down to questions. I thought where was no such thing as a stupid question.

That said, you can definitely use import or require. You're just going to have to use something like Browserify to make them work.

If you really want to get that way, I've got a repo here that I just set up to try out Noty stuff