代码之家  ›  专栏  ›  技术社区  ›  eth3rnit3

续集配置。json/config.js

  •  0
  • eth3rnit3  · 技术社区  · 7 年前

    我想更改 config.json 到 config.js 为了能够使用环境变量。

    const path = require('path');
    
    module.exports = {
      'config': path.resolve('config', 'config.js'),
      'models-path': path.resolve('models'),
      'seeders-path': path.resolve('seeders'),
      'migrations-path': path.resolve('migrations')
    }
    

    这与CLI sequelize的工作原理一样,我可以创建模型或启动迁移,但无法启动服务器,因为它会查找文件

    所以我的问题是如何确保服务器启动时能够读取 .

    node bin/www 我收到

    Error: Cannot find module '/nodeTest/nodejs-relationships/models/../config/config.json'
    
    0 回复  |  直到 7 年前
        1
  •  3
  •   eth3rnit3    7 年前

    问题其实是我的 index.js 文件位于 /models config.json 默认情况下,只需替换 .json .js

    推荐文章