久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 TypeScript 中需要 JavaScript Node.js 模塊(未設置a

Requiring a JavaScript Node.js module in TypeScript (allowJs#39; is not set)(在 TypeScript 中需要 JavaScript Node.js 模塊(未設置allowJs))
本文介紹了在 TypeScript 中需要 JavaScript Node.js 模塊(未設置allowJs')的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 Electron 中有一個 Angular2 應用程序.現在,我想使用 @pokusew/pcsclite 庫來使用 NFC 功能.該庫使用原生 Node.js 模塊.

I have an Angular2 app inside Electron. Now, I would like to use the @pokusew/pcsclite library to use NFC functionality. This library uses native Node.js modules.

當我嘗試 require 我的 component.ts 中的庫時,如下所示:

When I try to require the library in my component.ts like this:

declare var pcsclite: any;
var pcsclite = require('../../../node_modules/@pokusew/pcsclite/');

我收到錯誤提示:

錯誤 TS6143:模塊../.."已解析為../../lib/pcsclite.js",但未設置--allowJs".

error TS6143: Module '../..' was resolved to '../../lib/pcsclite.js', but '--allowJs' is not set.

另一方面,如果我嘗試通過 index.html 中的 <script>-Tag 導入庫,則會收到一條錯誤消息:

On the other hand, if I try to import the library via a <script>-Tag in the index.html I get an error that says:

ZoneAwareError 錯誤:找不到綁定文件.試過了:...

ZoneAwareError Error: Could not locate the bindings file. Tried:...

最后,如果我 var pcsclite = require('@pokusew/pcsclite');main.js 中,那么它可以工作,但是我沒有可以從我的 Angular 應用程序中訪問它.

Finally, if I var pcsclite = require('@pokusew/pcsclite'); in the main.js, then it works, but then I don't have access to it from inside my Angular app.

推薦答案

像這樣在 tsconfig.json 中添加 allowJs 選項:
正如 fabian lauer 所說,還添加了 outDir 選項來指定編譯文件的位置:

Add the allowJs option in your tsconfig.json like this:
as fabian lauer said also add outDir option to specify where your compiled files will be:

{
    "compilerOptions": {
        "outDir": "./built", <--- add this
        "allowJs": true,  <--- and this
        "target": "es5"
    },
    "include": [
        "./src/**/*"
    ]
}

這篇關于在 TypeScript 中需要 JavaScript Node.js 模塊(未設置allowJs')的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 亚洲综合视频在线 | 精品久久久久久久久久久久久久久久 | 欧美日韩国| 黄色片国产 | 在线欧美 | 亚洲综合天堂 | 国产乱淫片视频 | 专业操老外 | 日韩中文字幕在线视频 | 欧美日韩国产在线观看 | 香蕉久久久 | 逼逼操 | 一区二区三区四区在线 | av在线免费网站 | 欧美夜夜操 | 午夜精品久久久久久久久久久久 | 午夜婷婷 | 亚洲午夜视频在线观看 | 国产精品手机在线 | 99视频精品 | 日韩在线免费观看视频 | 一级片免费| 国产精品偷乱一区二区三区 | 国产伦精品一区二区 | 国产三级在线免费观看 | 欧美综合在线视频 | 99久久综合 | 无套内谢的新婚少妇国语播放 | 国产精品激情 | 成人在线网| 久热在线视频 | 日本不卡高字幕在线2019 | 一级片免费在线观看 | 免费a在线 | 精品一二三 | 欧美黄色一级大片 | 国产精品自拍一区 | 97在线免费视频 | 色婷婷av一区二区三区之e本道 | 国产成人精品一区二区三区在线 | 亚洲最大黄色网址 |