Cannot find module 'normalizr'


#1

Hi!

I’m trying to use ‘normalizr’ in my Ionic 2 app (See here: https://github.com/paularmstrong/normalizr).

I installed as instructed in the README:

npm install --save normalizr

And when I try to import using:

import {normalize, Schema, arrayOf} from 'normalizr';

I get an error from the Visual Studio and the TypeScript compiler in the terminal:

app/store/products/products.model.ts(5,42): Error TS2307: Cannot find module 'normalizr'.

I tried re-installing, manually removing node_modules dir and doing a fresh npm install without success.

Does anybody have a clue what I’m doing wrong?


#2

Hi,
Have you tried installing the Typescript typings for that library?.


#3

Hi!

Actually I did try:

bash-3.2$ typings search normalizr
Viewing 1 of 1

NAME      SOURCE HOMEPAGE                              DESCRIPTION VERSIONS UPDATED
normalizr dt     https://github.com/gaearon/normalizr/             1        2016-05-01T13:07:29.000Z
bash-3.2$ typings install --save normalizr
typings ERR! message Unable to find "normalizr" ("npm") in the registry. Did you want to try searching another source? Also, if you want contribute these typings, please help us: https://github.com/typings/registry
typings ERR! caused by https://api.typings.org/entries/npm/normalizr/versions/latest responded with 404, expected it to equal 200

typings ERR! cwd /Users/kim/ionic/Mindly
typings ERR! system Darwin 15.5.0
typings ERR! command "/Users/kim/.nvm/versions/node/v4.4.2/bin/node" "/Users/kim/.nvm/versions/node/v4.4.2/bin/typings" "install" "--save" "normalizr"
typings ERR! node -v v4.4.2
typings ERR! typings -v 1.0.4

typings ERR! If you need help, you may report this error at:
typings ERR!   <https://github.com/typings/typings/issues>

But I think it sounds wrong that I NEED the typings to import it. Typings should only be for the Intellisense in the editor, no?


#4

Take a look at this line:

NAME      SOURCE HOMEPAGE                              DESCRIPTION VERSIONS UPDATED
normalizr dt     https://github.com/gaearon/normalizr/             1        2016-05-01T13:07:29.000Z

the source is dt (DefinitelyTyped). According to Typings doc, you need to specify the source if it is not the default one (npm) and add --global arg in order to install it.

# If you use the package through script tag, or

it is part of the environment, or

# the non-global typings is not yet available:
typings install dt~mocha --global --save

#5

I see.

I installed the typings globally, and now there are no errors in Visual Studio. I thought all was good until I tried building:

TypeScript error: /Users/kim/ionic/Mindly/app/store/products/products.reducer.ts(2,42): Error TS2307: Cannot find module 'normalizr'.

It seems something else is wrong:-/

Thank you for your suggestions, it is appreciated!


#6

I hope this can help you:


#7

Thanks! I got it working:-)