How do I ensure a React NPM package using webpack can access required modules?


#1

In a meteor app, I’ve installed an npm package (react-sortable-tree) but I get the following error when the server starts (edited to show one of many such imports):

Unable to resolve some modules:

"!!../node_modules/css-loader/index.js??ref--1-1!../node_modules/postcss-loader/lib/index.js??ref--1-2!../node_modules/sass-loader/lib/loader.js!./tree-node.scss" in
/Users/administrator/Documents/Github Repos/treeDataExperiments/code/node_modules/react-sortable-tree/dist/main.js (web.browser)"

I found the following snippet in the main.js of the react-sortable-tree.js source code, which I suspect may relate to the issue- there is a var newContent that is being set to this very module, but it seems that webpack is being used to handle this import (is my guess, since I’ve never used webpack…):

var content = __webpack_require__(17);

/* ... some irrelevant code removed by OP ... */

// add the styles to the DOM
var update = __webpack_require__(4)(content, options);
if(content.locals) module.exports = content.locals;

// Hot Module Replacement
if(false) {
	// When the styles change, update the <style> tags
	if(!content.locals) {
		module.hot.accept("!!../node_modules/css-loader/index.js??ref--1-1!../node_modules/postcss-loader/lib/index.js??ref--1-2!../node_modules/sass-loader/lib/loader.js!./tree-node.scss", function() {
			var newContent = require("!!../node_modules/css-loader/index.js??ref--1-1!../node_modules/postcss-loader/lib/index.js??ref--1-2!../node_modules/sass-loader/lib/loader.js!./tree-node.scss");
			if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
			update(newContent);
		});
	}
	
        /* ... some irrelevant code removed by OP ... */

}

Where might I go from here, to gain some insight into what’s causing the issue?