如何将Jison 纳入Angular?

How to include Jison into Angular?

如何包含

Jison

javascript 库到 angular 项目?

目前我得到:

WARNING in ./node_modules/jison/node_modules/source-map/lib/source-map/source-node.js 8:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

GET http://localhost:4200/vendor.bundle.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK) inline.bundle.js:55 Uncaught TypeError: Cannot read property 'call' of undefined at webpack_require (inline.bundle.js:55)

安装到您的项目package.json

npm install jison -s

在您的 tsconfig.app.json 中,在 compilerOptions

的类型数组中包含 'node'
"compilerOptions": {
    "types": [
       "node"
    ]
}

然后将其导入任何 TypeScript 文件。

import * as jison from 'jison';