travelboy
travelboy

Reputation: 2697

Node import looking for main file of npm module in wrong place

I have published an npm module: react-bootstrap-tooltip-button

The package.json file states

"main": "lib/TooltipButton.js",

Installing the module as a dependency of another project using npm works fine, however, when I try to import it like so

import TooltipButton from 'react-bootstrap-tooltip-button'

I get an error revealing that node is looking for the main file in the wrong place:

Module not found: [CaseSensitivePathsPlugin]
`[...]/node_modules/react-bootstrap-tooltip-button/TooltipButton.js`
does not match the corresponding path on disk - File does not exist.

Why is lib/ missing in the path?

Upvotes: 1

Views: 1358

Answers (1)

travelboy
travelboy

Reputation: 2697

As it turns out, the code was fine, but this is a bug in Webpack. Restarting the dev server solved the problem (just recompiling wasn't enough).

Found the hint here: create-react-app issues on github

Upvotes: 1

Related Questions