Building a Node project using Esbuild and Typescript.
Might be related to https://github.com/dachev/node-cld/issues/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"
@seivan what directory did you ls in your last message? Was it ./node_modules/cld/build/Release?
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:
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'
]
}