我正在尝试创建迁移,但它抛出以下错误
yarn run v1.6.0
(node:14212) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usabil
ity issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods in
stead.
$ babel-node node_modules/.bin/knex migrate:make create_linky_table
C:\Users\Sagar\Desktop\linky\api\node_modules\.bin\knex:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.newLoader [as .js] (C:\Users\Sagar\Desktop\linky\lms-linky\api\node_modules\pi
rates\lib\index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)
我在 package.json 的脚本中设置了以下内容
"knex": "babel-node --require ./node_modules/dotenv/config node_modules/.bin/knex --knexfile='src/knexfile.js'",
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码来创建迁移
yarn knex make:migration create_linky_table
Run Code Online (Sandbox Code Playgroud)
我目前正在使用 Windows,我找到了这个答案。会不会是windows的问题?
@Mikael Lepist\xc3\xb6 所说的是正确的。
\n我在 Windows 上执行迁移脚本时遇到了类似的问题。
\n我之前的命令是:
\nbabel-node node_modules/.bin/knex --knexfile src/database/knexfile.js migrate:latest\nRun Code Online (Sandbox Code Playgroud)\n我把它改为:
\nbabel-node node_modules/knex/bin/cli.js --knexfile src/database/knexfile.js migrate:latest\nRun Code Online (Sandbox Code Playgroud)\n错误已经消失了。可能会将参考从 更改.bin/knex为/knex/bin/cli.js会给您带来魔力,所以尝试一下