3

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
  • 3,257
  • 5
  • 33
  • 43

3 Answers3

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
  • 3,257
  • 5
  • 33
  • 43
0

Hopefully this will help folks ...

You can use mv, to install Typescript; this seems good for me, but I don't go our of my way to use Typescript.

$ nvm  --version
$ nvm  use stable
$ npm  install typescript --save-dev
$ npx  tsc --version
Version 5.0.4
$ 

what seems to work is fine for me :-)

See also:

will
  • 4,799
  • 8
  • 54
  • 90