Sun Feb 20 2022·1 min read
Photo by Jamie Street
To solve the cannot find module 'typescript' error, make sure to install
typescript globally by running the
npm i -g typescript command and create a
symbolic link from the globally-installed package to
node_modules by running
npm link typescript command.
Open your terminal in your project's root directory and run the following commands:
# ✅ Install TypeScript globally npm install -g typescript # ✅ Create a symbolic link from the global package # to node_modules/ of current folder npm link typescript
Once you run the two commands, the error should be resolved.
If the global installation of TypeScript fails, you might have to run the
You can check if you have TypeScript installed successfully, by running the following command:
The output of the command should show the version of the TypeScript package on
your machine, e.g.
The npm link command creates
a symbolic link from the globally installed package to the
directory of the current folder.
If the error is not resolved, try to delete your
package-lock.json files, re-run
npm install and restart your IDE.
rm -rf node_modules package-lock.json npm install npm link typescript
Make sure to restart your IDE if the error still persists. VSCode glitches often and a reboot solves things sometimes.
If this also doesn't work, try installing TypeScript locally.
npm install --save-dev typescript
This will add typescript to the development dependencies of your project, so you
don't have to run the