我的问题是如何运行用ES6编写的sequelize
迁移/种子?
我尝试使用babel-node
,但收到奇怪的错误
命令
node_modules/babel-cli/lib/babel-node.js node_modules/sequelize-cli/bin/sequelize db:seed
错误
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.'
发布于 2019-06-10 00:38:57
实际上,如果我有问题的话,你应该在sequelize
中使用es6。
根据官方文档,您只需首先执行这些简单的步骤,安装babel依赖项,特别是@babel\register
npm install @babel\register
其次,在项目的根目录下创建一个.sequelizerc
并添加以下内容
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
记得玩得开心
发布于 2017-08-02 16:47:56
https://stackoverflow.com/questions/36632748
复制相似问题