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
```
This commit is contained in:
Clark Du 2018-08-07 19:50:04 +01:00 committed by GitHub
parent 24daeba035
commit 3b5a4709e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,6 +154,7 @@ export default class Renderer {
return return
} }
const hasModules = fs.existsSync(path.resolve(this.options.rootDir, 'node_modules'))
// Create bundle renderer for SSR // Create bundle renderer for SSR
this.bundleRenderer = createBundleRenderer( this.bundleRenderer = createBundleRenderer(
this.resources.serverBundle, this.resources.serverBundle,
@ -161,7 +162,8 @@ export default class Renderer {
{ {
clientManifest: this.resources.clientManifest, clientManifest: this.resources.clientManifest,
runInNewContext: false, 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 this.options.render.bundleRenderer
) )