Alex Taipale
Alex Taipale

Reputation: 61

My npm module build causing webpack error: Module not found: Error: Cannot resolve 'file' or 'directory'

I am trying to publish a fork of an open source React component to npm and use load it in my webpack after a successful npm install of my published module.

The webpack is throwing a Module not found: Error: Cannot resolve 'file' or 'directory' ./Slider.jsx in /home1... error when loading.

The lib/index.js file that my rc-tools build created is:

1'use strict';
2
3 module.exports = require('./Slider.jsx');

while, the main fork of the repo has

1'use strict';
2
3 module.exports = require('./Slider');

as their created lib/index.js.

I am using the same build (rc-tools) tool as them and have nearly identical package.json. Why is my repo creating a different index.js and is this the cause of my webpack.config not loading?

Here is the link to the npm component: https://www.npmjs.com/package/meraki-slider

Upvotes: 1

Views: 1068

Answers (1)

Alex Taipale
Alex Taipale

Reputation: 61

In my journey of learning about node and publishing, I simply forgot to remove the .jsx endings from my /src folder, which was causing my build to include them in my /lib folder and causing webpack to not compile. :P

Upvotes: 1

Related Questions