【问题标题】:Nodemon with express and nuxt带有 express 和 nuxt 的 Nodemon
【发布时间】:2021-04-08 23:03:54
【问题描述】:

我想监视使用 Nuxt 作为渲染引擎的快速应用程序的文件更改,但我无法让它工作,因为当我运行 nodemon app.js 时它会不断重建, 并且在运行时 nodemon app.js --ignore \".nuxt\" 不行

下面是我的快递代码:

const { loadNuxt, build } = require('nuxt')

const app = require('express')()
const isDev = process.env.NODE_ENV !== 'production'
const port = process.env.PORT || 3000

// Import Routes
const apiRoute = require('./routes/api');


async function start() {

  app.use('/api', apiRoute);

  // We get Nuxt instance
  const nuxt = await loadNuxt(isDev ? 'dev' : 'start')

  // Render every route with Nuxt.js
  app.use(nuxt.render)

  // Build only in dev mode with hot-reloading
  if (isDev) {
    build(nuxt)
  }
  // Listen the server
  app.listen(port, '0.0.0.0')
  console.log('Server listening on `localhost:' + port + '`.')
}

start()

【问题讨论】:

    标签: express nuxt.js nodemon


    【解决方案1】:

    只需添加 package.json:

    "scripts": {
           "dev": "cross-env NODE_ENV=development nodemon app.js --watch server",
            ....
      },
    

    【讨论】:

      猜你喜欢
      • 2017-02-22
      • 2014-09-24
      • 2021-01-28
      • 2014-07-02
      • 2017-09-15
      • 1970-01-01
      • 2018-11-04
      • 2016-10-20
      • 2019-05-25
      相关资源
      最近更新 更多