首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ES6和sequelize-cli

ES6和sequelize-cli
EN

Stack Overflow用户
提问于 2016-04-15 03:55:21
回答 2查看 7.4K关注 0票数 9

我的问题是如何运行用ES6编写的sequelize迁移/种子?

我尝试使用babel-node,但收到奇怪的错误

命令

代码语言:javascript
复制
node_modules/babel-cli/lib/babel-node.js node_modules/sequelize-cli/bin/sequelize  db:seed

错误

代码语言:javascript
复制
node_modules/babel-cli/lib/babel-node.js: line 1: /Applications: is a directory
node_modules/babel-cli/lib/babel-node.js: line 3: /Applications: is a directory
node_modules/babel-cli/lib/babel-node.js: line 4: 127.0.0.1: command not found
node_modules/babel-cli/lib/babel-node.js: line 5: syntax error near unexpected token `('
node_modules/babel-cli/lib/babel-node.js: line 5: ` * when found, before invoking the "real" _babel-node(1) executable.'
EN

回答 2

Stack Overflow用户

发布于 2019-06-10 00:38:57

实际上,如果我有问题的话,你应该在sequelize中使用es6。

根据官方文档,您只需首先执行这些简单的步骤,安装babel依赖项,特别是@babel\register

npm install @babel\register

其次,在项目的根目录下创建一个.sequelizerc并添加以下内容

代码语言:javascript
复制
 require("@babel\register");

    const path = require('path');

module.exports = {
  'config': path.resolve('config', 'config.json'),
  'models-path': path.resolve('models'),
  'seeders-path': path.resolve('seeders'),
  'migrations-path': path.resolve('migrations')
}

完成上述操作后,您可以开始在es6语法中使用sequelize

如需进一步阅读,请访问官方文档http://docs.sequelizejs.com/manual/migrations.html#using-babel

记得玩得开心

票数 7
EN

Stack Overflow用户

发布于 2017-08-02 16:47:56

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36632748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档