How to use with require in admin.js

Solved Plugin Development
  • #1

    I building plugin, I don't know how to add the require.main.require('./src/user') to admin.js (ACP settings)

    const User = require.main.require('./src/user');
    define('admin/plugins/quickstart', ['settings', 'autocomplete'], function (settings, autocomplete) {
    	var ACP = {};
    	ACP.init = function () {
    		autocomplete.user($('#username'), (ev, ui) => {
    		settings.load('quickstart', $('.quickstart-settings'));
    		$('#save').on('click', saveSettings);
    	function saveSettings() {'quickstart', $('.quickstart-settings'), function () {
    				type: 'success',
    				alert_id: 'quickstart-saved',
    				title: 'Settings Saved',
    				message: 'Please reload your NodeBB to apply these settings',
    				clickfn: function () {
    	return ACP;

    there is error in first line
    Uncaught TypeError: Cannot read properties of undefined (reading 'require') at admin.js:1

    How to do it?

  • GNU/Linux

    @yehonatan-albert You are not able to require server-side libraries from the client-side. You will need to make an API call from the client-side to do what you need to do.

  • #3

    @julian thanks!
    I successed with plugin socket

  • Y Yehonatan Albert marked this topic as a question on
  • Y Yehonatan Albert has marked this topic as solved on

Suggested Topics

| | | |