From 74aa94fac6f14425f84743b1b86a0b63c74b01a5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 1 Apr 2021 16:36:27 +0100 Subject: [PATCH] Fixing issue with node modules path. --- packages/server/src/api/controllers/static/index.js | 11 +++-------- packages/server/src/utilities/fileSystem/index.js | 9 +++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index fb9c16683c..cda18fbea5 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -13,6 +13,7 @@ const setBuilderToken = require("../../../utilities/builder/setBuilderToken") const { loadHandlebarsFile, NODE_MODULES_PATH, + TOP_LEVEL_PATH, } = require("../../../utilities/fileSystem") const env = require("../../../environment") const fileProcessor = require("../../../utilities/fileSystem/processor") @@ -33,7 +34,7 @@ async function checkForSelfHostedURL(ctx) { const COMP_LIB_BASE_APP_VERSION = "0.2.5" exports.serveBuilder = async function(ctx) { - let builderPath = resolve(NODE_MODULES_PATH, "builder") + let builderPath = resolve(TOP_LEVEL_PATH, "builder") if (ctx.file === "index.html") { await setBuilderToken(ctx) } @@ -94,13 +95,7 @@ exports.serveApp = async function(ctx) { exports.serveClientLibrary = async function(ctx) { return send(ctx, "budibase-client.js", { - root: join( - NODE_MODULES_PATH, - "node_modules", - "@budibase", - "client", - "dist" - ), + root: join(NODE_MODULES_PATH, "@budibase", "client", "dist"), }) } diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 17169528d3..d84c6deb8a 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -22,7 +22,8 @@ const fetch = require("node-fetch") const DEFAULT_AUTOMATION_BUCKET = "https://prod-budi-automations.s3-eu-west-1.amazonaws.com" const DEFAULT_AUTOMATION_DIRECTORY = ".budibase-automations" -const NODE_MODULES_PATH = join(__dirname, "..", "..", "..", "node_modules") +const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") +const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules") /** * The single stack system (Cloud and Builder) should not make use of the file system where possible, @@ -54,11 +55,10 @@ exports.checkDevelopmentEnvironment = () => { if (!isDev()) { return } - let error if (!fs.existsSync(budibaseTempDir())) { - error = - "Please run a build before attempting to run server independently to fill 'tmp' directory." + fs.mkdirSync(budibaseTempDir()) } + let error if (!fs.existsSync(join(process.cwd(), ".env"))) { error = "Must run via yarn once to generate environment." } @@ -237,4 +237,5 @@ exports.cleanup = appIds => { exports.upload = upload exports.retrieve = retrieve exports.retrieveToTmp = retrieveToTmp +exports.TOP_LEVEL_PATH = TOP_LEVEL_PATH exports.NODE_MODULES_PATH = NODE_MODULES_PATH