根据 TypeORM 文档,我正在尝试创建一个新的 TypeORM 项目并运行以下命令:
npm install typeorm -g
typeorm init --name MyProject --database postgres
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
TypeError: Cannot set property EntityManager of #<Object> which has only a getter
at Object.<anonymous> (~/.npm-global/lib/node_modules/typeorm/index.js:120:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (~/.npm-global/lib/node_modules/typeorm/commands/SchemaSyncCommand.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
Run Code Online (Sandbox Code Playgroud)
即使我只是尝试运行,我也会收到相同的错误
typeorm
Run Code Online (Sandbox Code Playgroud)
添加
"resolutions": {
"tslib": "1.11.2"
}
Run Code Online (Sandbox Code Playgroud)
到你的包 json,tslib 1.12 打破了 typeorm
好吧,显然 TypeORM 使用的依赖项之一存在问题。依赖项 tslib 1.12.0 显然破坏了 TypeORM。如果您已全局安装 TypeORM,请转到安装文件夹(默认位置可能是 /usr/local/lib/node_modules/typeorm)并编辑 package.json 文件。将 tslib 的版本更改为“1.11.2”。然后运行npm update以更新依赖项。