在我的应用程序中,我无法导入 sequelize
。这是错误
chunk {main} main.js, main.js.map (main) 2.02 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 691 bytes [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 9.77 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 339 kB [initial] [rendered] Date: 2020-04-16T08:48:36.690Z - Hash: 4a99c396b1a12d42e229 - Time: 5586ms
ERROR in node_modules/sequelize/types/lib/model.d.ts:345:5 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try
npm i @types/node
and then addnode
to the types field in your tsconfig.345 | Buffer // literal value ~~~~~~ node_modules/sequelize/types/lib/model.d.ts:354:24 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try
npm i @types/node
and then addnode
to the types field in your tsconfig.354 | (string | number | Buffer | WhereAttributeHash)[]; // implicit [Op.or] ~~~~~~ node_modules/sequelize/types/lib/model.d.ts:1371:44 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try
npm i @types/node
and then addnode
to the types field in your tsconfig.1371 export type Identifier = number | string | Buffer; ~~~~~~ node_modules/sequelize/types/lib/utils.d.ts:58:26 - error TS2503: Cannot find namespace 'NodeJS'.
58 export function stack(): NodeJS.CallSite[]; ~~~~~~
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
我的代码太简单了,我只调用了连接字符串,仅此而已
posts.component.ts
import { Component, OnInit, Input } from '@angular/core';
import { DataService } from '../data.service';
import { Observable } from 'rxjs';
import { Sequelize } from 'sequelize';
const sequelize = new Sequelize('postgres://postgres:1@localhost:3000/test1');
@Component({
selector: 'app-posts',
templateUrl: './posts.component.html',
styleUrls: ['./posts.component.css']
})
export class PostsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
请指出是什么问题?
[我正在尝试这样的事情:https://sequelize.org/v3/docs/getting-started/]
最佳答案
Sequelize 适用于服务器端,不适用于客户端。您应该从 Nodejs 后端使用它。
关于javascript - Angular:无法导入 Sequelize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61246371/