npm ‘module not found’, but everything seems to be set up correct

it seems my node_modules folder is being ignored. When I add new modules via 'npm install' the get installed correctly, but trying to import them results in a 'module not found' error. I can even delete the whole 'node_modules' folder and the app is still working.

I've installed some modules globally but I can't import them as well. It worked fine a couple a weeks ago, but now every change I do to the folder is being ignored...

npm: 5.5.1
node: 6.11.3
npm prefix: path/to/my/project
npm prefix -g: /usr/local
npm list --depth=0: returns my installed modules
npm install: installs the modules correctly into the 'node_modules' folder

Other technology used: React, JSX, Babel

I"m importing via import _ from 'lodash';

Any idea what's going on? I tried to solve the problem for two days now...

Examples:

npm install react-pdf --save

installs correctly into the node_modules folder and shows up under 'npm list --depth=0' but trying to import it results in:

Failed to compile.

Error in ./src/components/ProductSearch.js
Module not found: 'react-pdf' in /node/src/components

 @ ./src/components/ProductSearch.js 32:16-36

Updating react to 16.0.0 works well, I end up with 16.0.0 in my 'node_modules' folder but the app is still using 15.3.2



Read more here: https://stackoverflow.com/questions/47065455/npm-module-not-found-but-everything-seems-to-be-set-up-correct

Content Attribution

This content was originally published by Fjoergyn at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: