Typescript NPM Webpack Config Error

I’m trying to build an npm package for a Google Analytics configuration, however, I keep getting these errors.

Cannot find module ‘npm package’ or its corresponding type declarations.
Webpack build failed.

According to documentation here it’s because it is not compatible with webpack. I’ve been trying different builds and looking for comparable resources to get something working, but so far no luck.

Hi @jmvanhorn

If you have added the NPM package to your package.json file and your yarn.lock, and you are still seeing the error: “Cannot find module …”, please try using the following import syntax for your package

import * as name from "{package_name}/dist"

This workaround has resolved this type of issue before, and it possible that your problem is not related to package’s compatibility with Webpack.

Please try it and let me know.

Thanks Tielman, it worked!