beaugunderson / ip-address

šŸ’» a library for parsing and manipulating IPv4 and IPv6 addresses in JavaScript
http://ip-address.js.org/
MIT License
581 stars 73 forks source link

Uncaught ReferenceError: exports is not defined #176

Open David00 opened 2 hours ago

David00 commented 2 hours ago

Hello,

I feel that this is a very basic issue due to my unfamiliarity with Typescript and the use of larger javascript libraries.

I've built the library from version 10.0.1 and I'm trying to use it in my Flask webapp.

I'm importing ip-address.js and when loading the page, I get this in my console:

Uncaught ReferenceError: exports is not defined
    <anonymous> http://127.0.0.1:5000/static/js/ip-address.js:21

I must be importing the wrong file to use this library, but I searched the rest of the Javascript files that I built with tsc and I am unable to find where exports is actually defined. I've also tried importing common.js, but I get the same reference error about exports not being defined.

A "quick start" type guide to using this library would be wonderful to help users who are less familiar with frontend development get started with this library. I've seen https://ip-address.js.org/ but it looks like this only contains API reference material.

So, how do I use this library?

beaugunderson commented 1 hour ago

are you using a bundler or just building with tsc? if your project is open source or on github i'd be happy to take a look :)

On Tue, Nov 19 2024 at 15:21, David Albrecht @.***> wrote:

Hello,

I feel that this is a very basic issue due to my unfamiliarity with Typescript and the use of larger javascript libraries.

I've built the library from version 10.0.1 and I'm trying to use it in my Flask webapp.

I'm importing ip-address.js and when loading the page, I get this in my console:

Uncaught ReferenceError: exports is not defined

http://127.0.0.1:5000/static/js/ip-address.js:21 I must be importing the wrong file to use this library, but I searched the rest of the Javascript files that I built with tsc and I am unable to find where exports is actually defined. I've also tried importing common.js, but I get the same reference error about exports not being defined. A "quick start" type guide to using this library would be wonderful to help users who are less familiar with frontend development get started with this library. I've seen https://ip-address.js.org/ but it looks like this only contains API reference material. So, how do I use this library? ā€” Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
David00 commented 6 minutes ago

Thanks for the super quick response, Beau!

Unfortunately the project is not open source - it's for an internal tool I'm building for work. I am not using a bundler - I just built with tsc and copied the resulting JS files (and structure) from dist/ into my Flask project. Here's the resulting files and directory structure of the ip-address library within my Flask project:

~/python-projects/vxlan-automation/flask-app/src/static/js/ip-address$ tree .
.
ā”œā”€ā”€ address-error.d.ts
ā”œā”€ā”€ address-error.d.ts.map
ā”œā”€ā”€ address-error.js
ā”œā”€ā”€ address-error.js.map
ā”œā”€ā”€ common.d.ts
ā”œā”€ā”€ common.d.ts.map
ā”œā”€ā”€ common.js
ā”œā”€ā”€ common.js.map
ā”œā”€ā”€ ip-address.d.ts
ā”œā”€ā”€ ip-address.d.ts.map
ā”œā”€ā”€ ip-address.js
ā”œā”€ā”€ ip-address.js.map
ā”œā”€ā”€ ipv4.d.ts
ā”œā”€ā”€ ipv4.d.ts.map
ā”œā”€ā”€ ipv4.js
ā”œā”€ā”€ ipv4.js.map
ā”œā”€ā”€ ipv6.d.ts
ā”œā”€ā”€ ipv6.d.ts.map
ā”œā”€ā”€ ipv6.js
ā”œā”€ā”€ ipv6.js.map
ā”œā”€ā”€ v4
ā”‚Ā Ā  ā”œā”€ā”€ constants.d.ts
ā”‚Ā Ā  ā”œā”€ā”€ constants.d.ts.map
ā”‚Ā Ā  ā”œā”€ā”€ constants.js
ā”‚Ā Ā  ā””ā”€ā”€ constants.js.map
ā””ā”€ā”€ v6
    ā”œā”€ā”€ constants.d.ts
    ā”œā”€ā”€ constants.d.ts.map
    ā”œā”€ā”€ constants.js
    ā”œā”€ā”€ constants.js.map
    ā”œā”€ā”€ helpers.d.ts
    ā”œā”€ā”€ helpers.d.ts.map
    ā”œā”€ā”€ helpers.js
    ā”œā”€ā”€ helpers.js.map
    ā”œā”€ā”€ regular-expressions.d.ts
    ā”œā”€ā”€ regular-expressions.d.ts.map
    ā”œā”€ā”€ regular-expressions.js
    ā””ā”€ā”€ regular-expressions.js.map

2 directories, 36 files

...and I've tried importing ip-address.js, common.js, and ipv4.js from the top-level ip-address directory.