After creating my own npm package at https://www.npmjs.com/package/leon-theme?activeTab=code, I proceeded to set up a basic create-react-app project at https://github.com/leongaban/test-project.
In the src/index.tsx
file of my react app, I attempted to import my package using this line of code:
import { LeonTheme } from "leon-theme";
However, upon hovering over the import statement, an error message popped up:
Cannot find module 'leon-theme' or its corresponding type declarations.ts(2307)
tsconfig contents:
{
"compilerOptions": {
"module": "ES6",
"target": "es2016",
"lib": ["ES2020", "DOM"],
"jsx": "react",
"allowJs": true,
"declaration": true,
"declarationDir": "types",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"noEmit": false,
"outDir": "./dist",
"moduleResolution": "node",
"noImplicitAny": false
},
"include": ["src/**/*.ts"]
}
package.json details:
{
"name": "leon-theme",
"version": "0.0.15",
"module": "dist/lib/es6/index.js",
// additional package details...
}