Currently, I am in the process of publishing a package on npm
(this specific package). The package that I am developing utilizes webpack
and babel
, with the code written in ES6
. Within my source files, there is a file named index.js
that exports one of the main components of the library, which is as follows:
import TheGamesDb from './scrapers/thegamesdb';
export { TheGamesDb };
For the creation of the main file for my package, named index.js
, I am leveraging webpack
and babel
. The configuration in my webpack.config.js
is outlined below:
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: {
index: ['babel-polyfill', './src/index.js'],
development: ['babel-polyfill', './src/development.js']
},
output: {
path: '.',
filename: '[name].js',
library: 'rom-scraper',
libraryTarget: 'umd',
umdNamedDefine: true
},
devtool: 'source-map',
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
]
},
target: 'node',
externals: [nodeExternals()]
};
However, when attempting to import the export TheGamesDb
in another project by using the import statement below
import { TheGamesDb } from 'rom-scraper';
An error is encountered:
Uncaught TypeError: Path must be a string. Received undefined
Furthermore, it should be noted that the library is being imported into an electron
environment.
Update: It appears that the error is primarily occurring due to Electron, which is a dependency causing the issue (specifically in Electron environments).