Issue with require()

Hello there,

Apologies if this is a really basic thing. It’s quite likely i’m just not understanding how Includes works correctly. I have been trying to get this code working for the better part of the day now.

My build is throwing an error due to my API file not being included correctly

 [Viewport]: Error: : Uncaught require(): module not found: API in Fuse.Scripting.DiagnosticSubject<Javascript/LoginPage.js:3>


var userFunctions = require('userFunctions');
var ROOT_URL = "";

//Provides encapsulation for the api fetch
function apiFetch(path, options) {
	var url = encodeURI(ROOT_URL + path);
	if(options === undefined) {
		options = {};
	// If a body is provided, serialize it as JSON and set the Content-Type header
	if(options.body !== undefined) {
		options = Object.assign({}, options, {
			body: JSON.stringify(options.body),
			headers: Object.assign({}, options.headers, {
				"Content-Type": "application/json"

	// Fetch the resource and parse the response as JSON
		return fetch(url, options)
		.then(function(response) {
			return response.json();

//Logs the user in and passes the token over to userFunctions returns a 1 on succ 2 on bad login and 3 on error
function userLogin(args) {
	console.log("userLogin Function Initiated");

  return apiFetch("login.php", {
		method: "POST",
		body: {
			userEmail: args[0],
			userPassword: args[1]
	}).then(function(responseObject) {
    var tokenData = responseObject;

//Retrieves the categories and set lists for display
function getSets() {


//Retrieves a sets cards
function getCards() {


//Updates card QTY condition etc.. EZ worst function AU
function updateCard() {


module.exports = {
userLogin: userLogin,
getSets: getSets,
getCards: getCards,
updateCard: updateCard,


var Observable = require("FuseJS/Observable");
var API = require("API");

var userName = Observable("");
var userPassword = Observable("");
var data = Observable();

/*function init() {
	if (userFunctions.tokenSet()) {
		//dont display the login page and navigate to the root view.
		//console.log("userToken:" userFunctions.getToken());
	} else {

		//display the login page and deny access to any other activities

function loginClicked() {

	console.log("loginClicked Function intiated");
	//Collect the username and password and arrify it
	var args = [];
	//Pass the username and password args

module.exports = {
	userName: userName,
	userPassword: userPassword,
	loginClicked: loginClicked,



  "RootNamespace": "",
  "Packages": [
  "Includes": [
  "Projects": [
  "Excludes": [
  "FusePM": {
    "Dependencies": [

Any explanation of what i’m doing wrong would be fantastic. Thanks heaps. Also i apologise if this was posted under the wrong category.


Where in the file system is API, relative to your project and LoginPage.js? Even if the two files are both in your JavaScript folder, you need to reference API from the root of the project, like this: JavaScript/API.js

Hey there Liam. I have references it under includes in the project folder and it’s still throwing the error.

  "Includes": [

@Tarriq: as Liam suggested, the second line in your LoginPage.js needs to be:

var API = require("Javascript/API");