2

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

Wayne F. Kaskie
  • 2,541
  • 3
  • 22
  • 38

2 Answers2

0

When using nvm, every node version has it's own globally installed dependencies. If you are not finding something you have installed previously for a different version of node (or you have removed it), this can be a reason.

0

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
Wayne F. Kaskie
  • 2,541
  • 3
  • 22
  • 38