Nuxt错误app.listen()。然后不是一个函数

时间:2018-02-14 12:06:35

标签: node.js express nuxt.js

  

我正在关注此文档链接

https://nuxtjs.org/api/configuration-dev

  

当我在Windows机器上使用npm run dev-https命令以编程方式运行nuxt时出现以下错误。

     

app.listen(...)。然后不是函数

如果我像这样替换

,相同的代码将起作用
  

app.listen(port,host);

而不是

  

app.listen(port,host).then(()=> {         nuxt.showOpen()       })

const { Nuxt, Builder } = require('nuxt')
const app = require('express')()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 3000
console.log(host);

// We instantiate Nuxt.js with the options
let config = require('./nuxt.config.js')
const nuxt = new Nuxt(config)
app.use(nuxt.render)

// Build only in dev mode
if (config.dev) {
  new Builder(nuxt).build()
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
}

// Listen the server
app.listen(port, host).then(() => {
  nuxt.showOpen()
})
  

完整错误在

之下
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev-https' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'predev-https', 'dev-https', 'postdev-https' ]
5 info lifecycle nuxthello@1.0.0~predev-https: nuxthello@1.0.0
6 info lifecycle nuxthello@1.0.0~dev-https: nuxthello@1.0.0
7 verbose lifecycle nuxthello@1.0.0~dev-https: unsafe-perm in lifecycle true
8 verbose lifecycle nuxthello@1.0.0~dev-https: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\nuxtHello\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Oracle\VirtualBox;C:\HashiCorp\Vagrant\binC:\Program Files\Git\cmd;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\PuTTY\;C:\HashiCorp\Vagrant\bin;C:\Program Files\nodejs\;C:\Users\skumar\AppData\Local\GitHubDesktop\bin;C:\Users\skumar\AppData\Roaming\npm
9 verbose lifecycle nuxthello@1.0.0~dev-https: CWD: D:\nuxtHello
10 silly lifecycle nuxthello@1.0.0~dev-https: Args: [ '/d /s /c', 'node --max-old-space-size=10000 server.js' ]
11 silly lifecycle nuxthello@1.0.0~dev-https: Returned: code: 1  signal: null
12 info lifecycle nuxthello@1.0.0~dev-https: Failed to exec dev-https script
13 verbose stack Error: nuxthello@1.0.0 dev-https: `node --max-old-space-size=10000 server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid nuxthello@1.0.0
15 verbose cwd D:\nuxtHello
16 verbose Windows_NT 6.3.9600
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev-https"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error nuxthello@1.0.0 dev-https: `node --max-old-space-size=10000 server.js`
22 error Exit status 1
23 error Failed at the nuxthello@1.0.0 dev-https script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

0 个答案:

没有答案