我正在尝试按照本指南在Mac https://database.guide/how-to-install-sql-server-on-a-mac/中与docker一起使用mssql,但是当尝试连接到SQL Server时,出现SyntaxError:/ usr / local / lib / node_modules /中意外的保留字错误sql-cli / lib / cli.js:21
错误:
/usr/local/lib/node_modules/sql-cli/lib/cli.js:21
class SqlCli {
^^^^^
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/sql-cli/bin/mssql.js:1:76)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
代码:(不是我的)
...
class SqlCli {
constructor() {
this.db = new MSSQLDbService();
this.messages = new Messages();
this.options = new Options();
this.buffer = new Buffer();
}
...
我正在使用节点版本0.10.35,因为这是我的项目正在使用的版本,无法更改。
我看了您发布的教程,它使用npm下载SqlCli。
当您在类或文件中命名与node_modules中的程序包相同的名称时,它将与节点程序包冲突并最终给您带来致命错误,
尝试将类和文件名更改为其他内容,然后再次检查。
class DBCli {
constructor() {
this.db = new MSSQLDbService();
this.messages = new Messages();
this.options = new Options();
this.buffer = new Buffer();
}
}