npm Packages within Plugins

Hello! I’ve been having a lot of fun developing JS scripts for Kintone, and I’m currently moving on to developing my first plugin from scratch through plugin-packer.

I wanted to reference some npm packages (e.g. moment, sweetalert2), but get the following error when using ‘require’: “Uncaught ReferenceError: require is not defined”

For JS customizations, I was able to use ‘require’ references with no issues, likely because I bundled first through webpack before uploading to Kintone… but I’m wondering if plugin-packer acts differently (i.e. not necessarily bundling?). My plugin works perfectly if I remove the “require” and related functions.

The closest thing to this question I found was this article on the Japanese platform, but felt like plugins were a separate issue. Apologies if this is a duplicate question nonetheless.

Thank you in advance for any tips!

Hi Gaku,


Do you mind sharing your code with us so we could see the details?


Thank you,


Hi Sean:

I appreciate you offering help! But I’m not too sure how sharing any code would help in this instance.

The Import line:
const moment = require(‘moment’);

Update: Solution found!

Instead of plugin-packer, I was supposed to use webpack-plugin-kintone-plugin for my use case.

The current available tutorials are on the GitHub README or the Japanese guide here. Hopefully a full tutorial in English is on the way around here :slight_smile: