typescript error: Cannot find module '../build/Release/can.node'
technicallyfeasible opened this issue · comments
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.
Can you share minimal example?
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
@jbcpollak have you seen that before?
@technicallyfeasible using the tsconfig from socketcan directly "yarn build" runs through without any error.
hi apologies, I put my project down for a while - I'll take a look this weekend.
@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.
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.
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:
I believe the above referenced PR will fix this! Apologies for the delay.
Will release a new version, please check if that works for you too.
This works for me without errors, thanks for the quick fix 👍