Note: for support questions, please use one of these channels:
https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/
I added a library (TypeORM) to my ionic app and installed typings for node via npm install @types/node since they are required for this library. When running ionic-app-scripts build the transpile fails because it doesn't know about Buffer. When running tsc directly no errors are given.
I tried including the types in the tsconfig.json file, but that didn't change the output.
It should find and use the Node typings in node_modules/@types/node
Steps to reproduce:
npm install @types/nodebuild/browser/typeorm info node_modules/typeormapp.component.ts:constructor() {
createConnection({
type: "websql",
database: "test",
entities: [
User
],
autoSchemaSync: true,
logging: true
}).then(connection => {
console.log("Database loaded");
}).catch(error => {
console.log(error);
});
}
Which @ionic/app-scripts version are you using?
2.1.4
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
[11:27:11] transpile started ...
[11:27:18] typescript: <path>/node_modules/typeorm/driver/mongodb/MongoConnectionOptions.ts, line: 54
Cannot find name 'Buffer'.
L54: readonly sslCA?: string[]|Buffer[];
Forum post with more information
I added typeRoots to the tsconfig.json file but not in the compilerOptions.
This is the working tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Most helpful comment
I added
typeRootsto the tsconfig.json file but not in the compilerOptions.This is the working
tsconfig.json: