From 6208125ac0c2d6f43f4e43228bcab676b6833a04 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Mon, 19 Aug 2019 20:41:10 +0200 Subject: [PATCH] :sparkles: Serve editor-ui correctly also when installed as package --- packages/cli/src/Server.ts | 7 ++++++- packages/editor-ui/index.js | 0 packages/editor-ui/package.json | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/editor-ui/index.js diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 20987c08c0..d44ebbc2c5 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1,4 +1,8 @@ import * as express from 'express'; +import { + dirname as pathDirname, + join as pathJoin, +} from 'path'; import * as bodyParser from 'body-parser'; import * as history from 'connect-history-api-fallback'; import * as requestPromise from 'request-promise-native'; @@ -1092,7 +1096,8 @@ class App { // Serve the website - this.app.use('/', express.static(__dirname + '/../../node_modules/n8n-editor-ui/dist', { index: 'index.html' })); + const editorUiPath = require.resolve('n8n-editor-ui'); + this.app.use('/', express.static(pathJoin(pathDirname(editorUiPath), 'dist'), { index: 'index.html' })); } } diff --git a/packages/editor-ui/index.js b/packages/editor-ui/index.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index e13f0244d3..f0bd46a4f3 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -7,6 +7,7 @@ "name": "Jan Oberhauser", "email": "jan@n8n.io" }, + "main": "index.js", "repository": { "type": "git", "url": "git+https://github.com/n8n-io/n8n.git"