簡體   English   中英

無法編譯離子項目

[英]Failed to compile the ionic project

錯誤:此模塊是使用“export =”聲明的,並且只能在使用“allowSyntheticDefaultImports”標志時與默認導入一起使用。 文件中的錯誤:

1 從“form-data”導入FormData; ~~~~~~~~

node_modules/@kintone/rest-api-client/node_modules/form-data/index.d.ts:10:1

10 出口=表格數據; ~~~~~~~~~~~~~~~~~

這是文件的代碼:

// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
//                 Leon Yu <https://github.com/leonyu>
//                 BendingBender <https://github.com/BendingBender>
//                 Maple Miao <https://github.com/mapleeit>

/// <reference types="node" />
import * as stream from 'stream';
import * as http from 'http';

export= FormData;

// Extracted because @types/node doesn't export interfaces.
interface ReadableOptions {
highWaterMark?: number;
encoding?: string;
objectMode?: boolean;
read?(this: stream.Readable, size: number): void;
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => 
void): void;
autoDestroy?: boolean;
}

interface Options extends ReadableOptions {
writable?: boolean;
readable?: boolean;
dataSize?: number;
maxDataSize?: number;
pauseStreams?: boolean;
}

declare class FormData extends stream.Readable {
constructor(options?: Options);
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
submit(
  params: string | FormData.SubmitOptions,
  callback?: (error: Error | null, response: http.IncomingMessage) => void
): http.ClientRequest;
getBuffer(): Buffer;
getBoundary(): string;
getLength(callback: (err: Error | null, length: number) => void): void;
getLengthSync(): number;
hasKnownLength(): boolean;
}

declare namespace FormData {
interface Headers {
  [key: string]: any;
}

interface AppendOptions {
  header?: string | Headers;
  knownLength?: number;
  filename?: string;
  filepath?: string;
  contentType?: string;
}

interface SubmitOptions extends http.RequestOptions {
  protocol?: 'https:' | 'http:';
}

}

請嘗試將allowSyntheticDefaultImports: true添加到tsconfig並查看是否可以解決問題。

這是一個類似查詢的鏈接: 這個模塊是用'export ='聲明的,並且只能在使用'esModuleInterop'標志時與默認導入一起使用

此外,這里有一些編譯器選項: https://www.typescriptlang.org/docs/handbook/compiler-options.html

希望這會有所幫助。

您應該將 allowSyntheticDefaultImports 設置為 false 而不是 true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM