How to fix the 'Unable to find "react" ("npm") in the registry' error when using the tool Typings and TypeScript

During the last years we see that every month new JavaScript frameworks/ tools/ libraries are comming out to the public and they all promise to help us develop better, faster and give more quality to our applications. One of the favorite combinations is currently the use of the React framework, TypeScript as superset of JavaScript and the webpack tool for combining files together, dependencies and more.

When using the combination, it is very probably that you are also going to use the Typings plugin for fast downloading of definitions files for TypeScript.

If you installed react with npm and you get the ‘Unable to find “react” (“npm”) in the registry’ error from Typings when you try to download the d.ts file of react, then here is the solution to your problem:

The error you get is going to look like this:

The unable to find react error when using typings

You probably used the following command to download the definition file:

typings install --ambient --save react

However, you probably installed globally the latest version (1.0) of Typings from npm with this command: npm install -g typings.

The previous command for getting React’s dt.s can be used only up to a 0.x version of Typings. You will have to replace the react-command with the following, when you use the 1.0 version:

typings install dt~react --global --save

As you can see the ambient keyword was replaced by the global keyword and by using the dt keyword you explicitly request to get the definition file from DefinitelyTyped repository.

Apart from this change, the new command generates a folder typings with an index.d.ts file which contains all the references to the d.ts you installed. This is different from the 0.x version of typings, since there you get a main and a browser file.

I hope I could help with this problem. Drop me a line if you have any comments.

comments powered by Disqus