Ad

Cannot Find Typescript Using NVM

- 1 answer

I have nvm installed and recently fixed an issue with a conflict with a previously installed version of node. Fixing it meant removing the node executable from the prior location. Some things still work but I'm getting this error: Cannot find module 'typescript'

and this fix didn't help me: How to fix Cannot find module 'typescript' in Angular 4?

running ng new is what is triggering the error.

I have typescript installed globally. And to ensure that is installed with this version of node, I ran:

nvm use 10 && npm i -g typescript
/Users/username/.nvm/versions/node/v10.16.0/lib/node_modules/typescript/bin/tsserver

Thanks, Wayne

Ad

Answer

For anyone coming across this question, I found the answer here. How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

I had to do all of the steps in the most accepted answer. I also had to:

rm -Rf /user/local/bin/node_modules

It might be a good idea to search your machine for all node_modules folders and, of course, ignore any "local" versions. And delete all of them that are not in your nvm directory. That directory will look somehting like:

/Users/username/.nvm/versions/node/v#####/lib/node_modules

You can identify yours using:

npm root -g
Ad
source: stackoverflow.com
Ad