javascript - Angular:无法导入 Sequelize

标签 javascript node.js angular typescript sequelize.js

在我的应用程序中,我无法导入 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 add node 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 add node 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 add node 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/

相关文章:

javascript - $(document).width() 包括 ie8 中的滚动条

JavaScript if() 语句未按预期评估

javascript - Node Js Express JS 错误处理麻烦

node.js - 在CF中调试nodejs应用程序

javascript - 如何在 Angular 9 中使用 print.js 打印多个 PDF

javascript - 应用程序的脚本安全搜索框

javascript - pm2 不使用实验模块标志

Angular 2 中的 JSON 管道不起作用

javascript - Angular 8 项目中的外部 .js 文件

php - 在设定的时间段内显示图像和脚本