问题
Need help on getting babyparse module working in Electron, after npm install babyparse
module and still getting Uncaught Error: Cannot find module 'babyparse'
.
var Baby = require("babyparse");
window.$ = window.jQuery = require('./jquery.min.js');
var csv;
function readyFn(d){
parsed = Baby.parse(csv);
Papa.parse(data, {
complete: function(results) {
console.log("Finished:", results.data);
}
});
}
$(document).ready(readyFn);
回答1:
I had to re-bind require
to window
before using it.
In your index.html file (loaded my Electron), before loading your js, add window.nRequire = require
. Then call var Baby = nRequire("babyparse");
anywhere in your app.
回答2:
You could try following:
- check if the module is inside your node_modules folder of your electron app.
- If it is not install it via
npm install babyparse --save
be sure that you have the "--save" at the end, to install it inside your app and not global. - If it is allready inside your node_modules folder, maybe something went wrong, when you installed it. So uninstall it
npm uninstall babyparse --save
and install it again. Or better you could also run a complete npm install inside your electron folder for updating all your modules.
回答3:
- Remove your node_modules folder
npm cache clean
npm install
来源:https://stackoverflow.com/questions/33856012/node-module-in-electron