sebi2k1 / node-can

NodeJS SocketCAN extension
215 stars 72 forks source link

typescript error: Cannot find module '../build/Release/can.node' #116

Closed technicallyfeasible closed 1 year ago

technicallyfeasible commented 1 year ago

I just upgraded to the latest version and am unable to compile my typescript app because of this error:

node_modules/socketcan/dist/socketcan.d.ts:1:22 - error TS2307: Cannot find module '../build/Release/can.node' or its corresponding type declarations.

1 import * as can from "../build/Release/can.node";

From what I can tell this is because the compiler cannot find the can.d.ts declaration because it is not part of the dist or release folders but remains in src.

Additionally, the exported type for "Message" is not the same as "Message" on RawChannel (which is not exported) so I am not able to properly type rawChannel.send(message) calls.

sebi2k1 commented 1 year ago

Can you share minimal example?

technicallyfeasible commented 1 year ago

Here is a minimal example: socketcan_test.zip

I am running node 16.18.0

install node_modules with yarn and build using yarn build

sebi2k1 commented 1 year ago

@jbcpollak have you seen that before?

sebi2k1 commented 1 year ago

@technicallyfeasible using the tsconfig from socketcan directly "yarn build" runs through without any error.

jbcpollak commented 1 year ago

hi apologies, I put my project down for a while - I'll take a look this weekend.

technicallyfeasible commented 1 year ago

@sebi2k1 that's not really the point, is it? It's supposed to work with most typescript configurations, you can't require people to use a specific config just so that your library works. I went through the options in the socketcan tsconfig.json and adding "skipLibCheck": true, will not report the error anymore. However, I would prefer not adding that as it makes types in general less accurate.

sebi2k1 commented 1 year ago

Happy for another proposal how to solve it. I couldn’t find details yet. It’s a problem with the native modules but it’s not the location of the artificats.

jbcpollak commented 1 year ago

Hi, I just whipped up an example project and was about to post it when I noticed I have skipLibCheck enabled on it. I'm out of time right now but will look into it and will see if I can remove it asap. here is the project in the meantime:

https://github.com/arcmotive/scutils-ts

jbcpollak commented 1 year ago

I believe the above referenced PR will fix this! Apologies for the delay.

sebi2k1 commented 1 year ago

Will release a new version, please check if that works for you too.

technicallyfeasible commented 1 year ago

This works for me without errors, thanks for the quick fix 👍