4

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

1
  • Do you have typescript installed globally? If yes, try to execute npm i, before you run ng new. Commented Jul 11, 2019 at 13:10

3 Answers 3

4

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:

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.