From 3b5a4709e8e023bfdce12f9d03fce443e87a4251 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 7 Aug 2018 19:50:04 +0100 Subject: [PATCH] feat: support global command-line build and start (#3647) With this pr, user can install nuxt globally, then start or build simple repos without npm /yarn install: ```bash npm i nuxt-edge -g nuxt dev/build/start ``` --- lib/core/renderer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index d19b3d1f90..30c324e35c 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -154,6 +154,7 @@ export default class Renderer { return } + const hasModules = fs.existsSync(path.resolve(this.options.rootDir, 'node_modules')) // Create bundle renderer for SSR this.bundleRenderer = createBundleRenderer( this.resources.serverBundle, @@ -161,7 +162,8 @@ export default class Renderer { { clientManifest: this.resources.clientManifest, runInNewContext: false, - basedir: this.options.rootDir + // for globally installed nuxt command, search dependencies in global dir + basedir: hasModules ? this.options.rootDir : __dirname }, this.options.render.bundleRenderer )