Reputation: 3072
I'm trying to use Summernote in an Electron app, but i keep getting this error when i include summernote.js in my project:
Uncaught Error: Cannot find module 'jquery' at Module._resolveFilename (module.js:470:15) at Function.Module._resolveFilename (C:\Users\me\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at file:///C:/Users/me/projects/FO/dist/vendors/summernote/summernote.js:18:30 at file:///C:/Users/me/projects/FO/dist/vendors/summernote/summernote.js:23:2
I have included jQuery in my project and i'm using other jQuery plugins without any problems:
<script>
window.$ = window.jQuery = require('./vendors/jquery-1.12.4-dist/jquery-1.12.4.min.js');
</script>
UPDATE: This only happens with Summernote version above 0.6.16. I was initially using 0.8.2 and when i changed the ver to 0.6.16 the error disappeared.
Any ideas how to resolve this issue?
Upvotes: 1
Views: 1146
Reputation: 1
<script src="../../node_modules/jquery/dist/jquery.js"></script>
<script src="../../node_modules/jquery/dist/jquery.min.js"></script>
<script>
if (typeof module === 'object')
{window.module = module; module = undefined;}
</script>
<script src="../../node_modules/popper.js/dist/umd/popper.js."></script>
<script src="../../node_modules/popper.js/dist/umd/popper.min.js"></script>
<script src="../../node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="../../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../../node_modules/summernote/dist/summernote.js"></script>
<script src="../../node_modules/summernote/dist/summernote.min.js"></script>
<script>
$(function () { $('#editor').summernote(); });
</script>
summernote-lite don't use bootstrap however with bs4 we need that. the libraries should be added in the above way. some time order of loading js libraries are creating issues are creating issues. if bootstrap needs proper.js file. -- this is a working sequence in electron project
Upvotes: 0
Reputation: 1
The old summernote.js looked like this:
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(window.jQuery);
}
the new one looks like this:
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(window.jQuery);
}
because electron contains require() it tries to load it like a node module and fails. You can solve this by just commenting the part for node.
Upvotes: 0