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

Building a Node project using Esbuild and Typescript. #76

Open
seivan opened this issue Mar 10, 2023 · 2 comments
Open

Building a Node project using Esbuild and Typescript. #76

seivan opened this issue Mar 10, 2023 · 2 comments

Comments

@seivan
Copy link

seivan commented Mar 10, 2023

Might be related to #67
But I am having some issues using cld in a Node project using esbuild and Typescript.

$ yarn run make                                                                                  
✘ [ERROR] Could not resolve "./build/Release/cld"

    .yarn/unplugged/cld-npm-2.9.0-8b7667576b/node_modules/cld/index.js:2:21:
      2 │ const cld2 = require('./build/Release/cld');

Not sure if the path is being used relative to my cwd (since that's wrong) or if something is missing in the <modules_folder>/build/Release folder?

$ ls                                                                                     
cld-c.a    cld.node   obj.target

These are the files there.
It only happens when compiling using esbuild. Doesn't happen with ts-node for instance.

This is how I run it

esbuild src/main.ts --bundle --sourcemap --platform=node --target=ES2022 --outfile=build/dist/main.js

This is how I import it

import { detect } from "cld"
@dachev
Copy link
Owner

dachev commented Mar 11, 2023

@seivan what directory did you ls in your last message? Was it ./node_modules/cld/build/Release?

@GA1
Copy link

GA1 commented Nov 27, 2023

Hey @dachev, any update on this? I'm having the same issue:

When using the library in typescript with:
import cld from 'cld'

I get:

in my IDE:

Screenshot 2023-11-27 at 11 43 16

in my terminal when running the project:

 Error: Cannot find module './build/Release/cld'
 Require stack:
   - ***********************************************/node_modules/cld/index.js
       at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
     at Module._load (node:internal/modules/cjs/loader:841:27)
     at Module.require (node:internal/modules/cjs/loader:1061:19)
     at require (node:internal/modules/cjs/helpers:103:18)
     at Object.<anonymous> (********************************************************/node_modules/cld/index.js:2:14)
       at Module._compile (node:internal/modules/cjs/loader:1159:14)
       at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
       at Module.load (node:internal/modules/cjs/loader:1037:32)
       at Module._load (node:internal/modules/cjs/loader:878:12)
       at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29) {
       code: 'MODULE_NOT_FOUND',
     requireStack: [
         '***********************************************/node_modules/cld/index.js'
       ]
     }

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

3 participants