GithubHelp home page GithubHelp logo

Nest.js: Unable to import about tle.js HOT 12 CLOSED

theheckwr avatar theheckwr commented on August 19, 2024
Nest.js: Unable to import

from tle.js.

Comments (12)

theheckwr avatar theheckwr commented on August 19, 2024 2

Okay, thanks for the info and the "temporary" solution.
That's way better than my workaround. I've implemented it and it works so far.
Let's hope they'll implement it soon.

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024 1

Great, glad that works! I am seeing a similar error with a simple Node project so I think I may be packaging it a bit wrong as well, looking into this!

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024 1

Oof, thanks for the heads up, I'm not sure what's going on there. As a workaround you'll have to lock it down to the prior version for now (npm i [email protected]). Sorry for the hassle!

from tle.js.

theheckwr avatar theheckwr commented on August 19, 2024 1

Yes, that's what I did already.
But thanks anyways for the help so far.

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024 1

When you have a chance, please try again with 4.5.3, I believe I finally tracked down the issue! Thanks again.

from tle.js.

theheckwr avatar theheckwr commented on August 19, 2024 1

Okay, I tested it.
It works so far. No errors and the functions I'm using are executing normally, as far as I see. Even with Nest.js.
Thanks very much!

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024

Thanks for the heads up, it looks like Nest.js doesn't yet support ES Modules: nestjs/nest#8736 (also see nestjs/nest#7021)

The good news is that it's a quick fix for you - you can tell it to explicitly use the CommonJS dist instead:

const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

I verified this works by running their TypeScript starter project and outputting some test code in their app.service.ts Hello World (note that I'm using Node 16.13.1):

import { Injectable } from '@nestjs/common';
const { getLatLngObj } = require("tle.js/dist/tlejs.cjs");

const tle = `ISS (ZARYA)
1 25544U 98067A   17206.18396726  .00001961  00000-0  36771-4 0  9993
2 25544  51.6400 208.9163 0006317  69.9862  25.2906 15.54225995 67660`;

@Injectable()
export class AppService {
  getHello(): string {
    return `Hello World! ${JSON.stringify(getLatLngObj(tle))}`;
  }
}

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024

In tle.js 4.5.0 I've added Node.js conditional exports support which seems to resolve the issue!

from tle.js.

theheckwr avatar theheckwr commented on August 19, 2024

Unfortunately when I try to import this version with TypeScript into my Nest.js project, that fails with a "Can't find module declaration or corresponding type declaration" (Even my IDE (vs-code) shows this...).
Maybe this is a problem again with Nest.js but it looks like a TypeScript thing to me. Maybe something with my TypeScript config?

Additionally the other way you described before now gives an error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/tlejs.cjs' is not defined by "exports" in <redacted>/node_modules/tle.js/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:299:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:522:3)
    at resolveExports (internal/modules/cjs/loader.js:449:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:489:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (<redacted>/src/services/spacecraft-data.service.ts:5:84)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024

Woo! Good stuff, thanks for your patience!

from tle.js.

thkruz avatar thkruz commented on August 19, 2024

@davidcalhoun can you close this?

from tle.js.

davidcalhoun avatar davidcalhoun commented on August 19, 2024

Sounds good, closing this out!

from tle.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.