react-starter-kit icon indicating copy to clipboard operation
react-starter-kit copied to clipboard

Cannot find module ... TypeScript error in VSCode

Open stephyswe opened this issue 3 years ago • 1 comments

After cloning, running "yarn install", then "yarn start" I get the following error messages. Full log: https://gist.github.com/stephyswe/8c6a749304aaeb84a3450258688e2ba5

  ➜  Local:   http://127.0.0.1:5173/
  ➜  Network: use --host to expose
X [ERROR] Could not resolve "./C:/Users/Stephanie/AppData/Local/Yarn/Berry/cache/firebase-npm-9.9.1-4f1112f562-9.zip/node_modules/firebase/auth/dist/index.esm.js"

    dep:firebase_auth:2:14:
      2 │ export * from "./C:/Users/Stephanie/AppData/Local/Yarn/Berry/cache/firebase-npm-9.9.1-4f1112f562-9.zip/node_modules/firebase/auth/dist/index.esm.js" 

FIX - yarn set version latest it set package.json to a lower yarn version. "packageManager": "[email protected]", to "packageManager": "[email protected]", then , yarn install, yarn start, started with no errors. not sure why.

Another issue not related is that inside an .tsx file (App.tsx) get syntax error. not sure why is there a workaround?

image

stephyswe avatar Aug 01 '22 07:08 stephyswe

@stephyswe please ensure that you're using the local (workspace) version of TypeScript in VSCode (Shift + Cmd + P)

image

image

Note, that the project is configured to use Yarn with PnP; it's also possible to configure Yarn to use node_modules folder instead (via yarn config set nodeLinker node-modules then removing PnP paths from .vscode/settings.json).

Another thing to consider, the moduleResolution is set currently set to NodeNext which only works with modern TypeScript and dependencies. If you bump into an issue when some dependency doesn't work well with it, you can change it to Node here:

https://github.com/kriasoft/react-starter-kit/blob/b7e2a1f391fb3ac451d7eec5fded16f02c8d1e04/app/tsconfig.json#L9

You can also check if TypeScript works locally by running yarn tsc --build and checking the TypeScript extension's log in VSCode > Terminal > Output.

koistya avatar Aug 01 '22 16:08 koistya