node.js - TypeORM hibák az fs, buffer és stream használatakor
A nevem George, és első alkalommal programozom Angularban, és problémáim vannak a Typescript-tel és a TypeORM-mel.
Amikor lefordítom a kódot, ezeket a hibákat adja
node_modules/typeorm/driver/mongodb/MongoConnectionOptions.d.ts(53,33): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/MongoConnectionOptions.d.ts(58,33): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/MongoConnectionOptions.d.ts(63,32): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anodeértéket a tsconfig types mezőjéhez.node_modules/typeorm/driver/mongodb/MongoConnectionOptions.d.ts(68,33): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(92,13): hiba TS2580: Nem található a(z) 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(294,19): hiba TS2580: Nem található a(z) 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(298,15): error TS2580: Nem található a 'Buffer' név. Szükséges a node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(302,14): error TS2580: Nem található a 'Buffer' név. Szükséges a Node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anodeelemet a types mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(306,15): hiba TS2580: Nem található a(z) 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(365,19): hiba TS2580: Nem található a(z) 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(369,15): error TS2580: Nem található a 'Buffer' név. Szükséges a Node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(373,14): error TS2580: Nem található a 'Buffer' név. Szükséges a node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(377,15): error TS2580: Nem található a 'Buffer' név. Szükséges a node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(416,19): hiba TS2580: Nem található a(z) 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(420,15): error TS2580: Nem található a 'Buffer' név. Szükséges a node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(424,14): error TS2580: Nem található a 'Buffer' név. Szükséges a Node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig fájlban.node_modules/typeorm/driver/mongodb/typings.d.ts(428,15): error TS2580: Nem található a 'Buffer' név. Szükséges a node típusdefiníciók telepítése? Próbálja ki a
npm i @types/nodeparancsot, majd adja hozzá anode-t a típusok mezőhöz a tsconfig-jában.node_modules/typeorm/driver/mongodb/typings.d.ts(1591,25): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(1636,45): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(1647,19): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4233,34): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4317,21): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4478,34): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4526,21): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4595,34): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/driver/mongodb/typings.d.ts(4627,21): hiba TS2580: Nem található a 'Buffer' név. Szükséges lehet a node típusdefinícióinak telepítése. Próbáld meg a
npm i @types/nodeparancsot, majd add hozzá anode-t a types mezőhöz a tsconfig fájlodban.node_modules/typeorm/platform/PlatformTools.d.ts(2,28): hiba TS2307: Nem található a 'fs' modul.
node_modules/typeorm/platform/PlatformTools.d.ts(4,36): hiba TS2307: Nem található a 'stream' modul.
node_modules/typeorm/platform/PlatformTools.d.ts(38,44): hiba TS2580: Nem található a 'Buffer' név. Szükséges telepíteni a node típusdefiníciókat? Próbálja meg
npm i @types/nodeparancsot, majd adja hozzá anodeértéket a types mezőhöz a tsconfig fájlban.**
ez az én tsconfig fájlom
{
"compilerOptions": {
"lib": [
"es5",
"es6",
"dom"
],
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"types": [
"node"
],
"typeRoots": ["node_modules/@types"]
},
"exclude": [
"node_modules",
]
}
Miért ez a hiba?
Válasz #1
Nagyon hasonló hibám volt egy Ionic/Angular 7 és AWS Amplify projekt esetén. Íme a hiba kimenetének egy része:
...
[ng] ERROR in node_modules/aws-sdk/clients/acm.d.ts(133,37): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acm.d.ts(135,38): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acm.d.ts(469,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acm.d.ts(471,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acmpca.d.ts(283,37): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acmpca.d.ts(285,38): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/acmpca.d.ts(353,25): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/apigateway.d.ts(1150,23): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/appsync.d.ts(248,23): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/clouddirectory.d.ts(1571,38): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
[ng] node_modules/aws-sdk/clients/cloudsearchdomain.d.ts(7,24): error TS2307: Cannot find module 'stream'.
...
Sajnos az a megoldás, hogy követtem a hiba által javasolt utasításokat, nem volt a megoldásom. Ehelyett a tsconfig.app.json fájlt kellett szerkesztenem, és teljesen el kellett távolítanom az üres típusokat "types": []
Így szokott ez lenni:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
és így vált:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app"
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
Ha vannak bejegyzéseid a types tömbben, akkor nincs probléma, és nem kellene, hogy a korábban leírt hibát tapasztald.
Ez akkor jelenik meg, amikor a tömb üres.
Válasz #2
próbáld meg így a tsconfig.app.json fájlban
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": [
"node"
],
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]}
