Dim*_*nov 5 javascript node.js sequelize.js ecmascript-6 babeljs
我的问题是如何运行sequelize用ES6编写的迁移/种子?
我尝试了babel-node,但出现了奇怪的错误
命令
node_modules/babel-cli/lib/babel-node.js node_modules/sequelize-cli/bin/sequelize db:seed
Run Code Online (Sandbox Code Playgroud)
错误
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.'
Run Code Online (Sandbox Code Playgroud)
实际上,如果我有问题,您想将 es6 与sequelize.
根据官方文档,您只需首先执行此简单步骤,尤其是安装 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')
}
Run Code Online (Sandbox Code Playgroud)
完成上述操作后,您可以开始使用带有 es6 语法的 sequelize
如需进一步阅读,您可以访问官方文档 http://docs.sequelizejs.com/manual/migrations.html#using-babel
记得玩得开心
| 归档时间: |
|
| 查看次数: |
3477 次 |
| 最近记录: |