2

I keep getting TS2307 Cannot find module error whenever I run typescript checks on my project. The src/index.ts file has the following imports:

import BigNumber from 'bignumber.js';
import {WebBundlr} from '@bundlr-network/client';
import {Connection} from '@solana/web3.js';
import type {Adapter} from '@solana/wallet-adapter-base';

and my tsconfig.json file:

{
  "compilerOptions": {
    "target": "esnext" ,
    "module": "esnext" ,
    "moduleResolution": "node" ,
    "baseUrl": "." ,
    "paths": {
      "*": ["src/*", "node_modules/*"]
    } ,
    "resolveJsonModule": true ,
    "noResolve": true ,
    "allowJs": true ,
    "checkJs": true ,
    "declaration": true ,
    "declarationDir": "declarations" ,
    "isolatedModules": true ,
    "allowSyntheticDefaultImports": true ,
    "esModuleInterop": true ,
    "forceConsistentCasingInFileNames": true ,
    "strict": true ,
    "noUnusedLocals": true ,
    "noUnusedParameters": true ,
    "noImplicitReturns": true ,
    "noFallthroughCasesInSwitch": true ,
    "skipLibCheck": true 
  },
  "include": ["src"],
  "exclude": ["node_modules"]
}

According package.json and node_modules folder all packages are already installed and all of them are supposed to have built-in types:

// package.json
{
  "name": "my-lib",
  "version": "0.0.1",  
  "main": "lib/index.cjs.js",
  "module": "lib/index.esm.js",
  "types": "lib/index.d.ts",
  "browser": {
    "./lib/index.cjs.js": "./lib/index.browser.cjs.js",
    "./lib/index.esm.js": "./lib/index.browser.esm.js"
  },
  "files": [
    "/lib",
    "/src"
  ],
  "dependencies": {
    "@bundlr-network/client": "^0.8.5",
    "@solana/wallet-adapter-base": "^0.9.16",
    "@solana/web3.js": "^1.59.1",
    "big-number": "^2.0.0",

    ....
    ....
  },

But I keep getting module not found errors for all those libraries:

enter image description here

What can I do to fix this problem?

1
  • Did you find any solutions?
    – brknarsy
    Commented Nov 2, 2023 at 17:41

1 Answer 1

1

According package.json all packages are already installed and all of them are supposed to have built-in types:

The name of packages in package.json file doesn't mean they are already installed. Run npm install command first to install the packages.

1
  • In my case I use yarn install, but yes they are already installed and can be checked on folder node_modules and yarn.lock but that is definitely not the issue, I rather think it has something to do with the Typescript configuration.
    – Ander
    Commented Oct 4, 2022 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.