首页 > 解决方案 > 将库分发到其他计算机时,A​​ngular 6 库找不到 node_modules 的相对路径

问题描述

原始 TypeScript 文件

import { Injectable } from '@angular/core';
import { transaction, snapshotManager } from '@datorama/akita';
import { tap } from 'rxjs/operators';
import { Business, transformBusiness } from 'smb-sp-models/business';
import { BusinessStore } from './business.store';
import { BusinessDataService } from './business-data.service';


@Injectable({
providedIn: 'root'
})
export class BusinessService {

    constructor(
        private businessStore: BusinessStore,
        private businessDataService: BusinessDataService
    ) {        
    }

    setQueryString(query: string) {
        this.businessDataService.setQueryString(query);
    }

    get() {
        return this.businessDataService.get().pipe(tap( (data: any) => {
            this.businessStore.set(data.data);
        }));
    }

    getById(id: string) {
        return this.businessDataService.getById(id).pipe(tap( (data: any) => {
            const entity = data;
            this.businessStore.createOrReplace(entity.businessId, entity);
        }));
    }

    getPage(opt?) {
        return this.businessDataService.get(opt);
    }

    @transaction()
    add(entity: Business) {
        this.businessStore.add(entity);
        return this.businessDataService.add(entity);
    }

    @transaction()
    update(entity: Business) {
        this.businessStore.update(entity.businessId, entity);
        return this.businessDataService.update(entity);
    }

    @transaction()
    replace(entity: Business) {
        this.businessStore.createOrReplace(entity.businessId, entity);
    }

    @transaction()
    remove(entity: Business) {
        this.businessStore.remove(entity.businessId);
    }

}

运行 ng build 后在 dist 文件夹中的文件

import { Business } from 'smb-sp-models/business';
import { BusinessStore } from './business.store';
import { BusinessDataService } from './business-data.service';
export declare class BusinessService {
    private businessStore;
    private businessDataService;
    constructor(businessStore: BusinessStore, businessDataService: BusinessDataService);
    setQueryString(query: string): void;
    get(): import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/rxjs/internal/Observable").Observable<any>;
    getById(id: string): import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/rxjs/internal/Observable").Observable<any>;
    getPage(opt?: any): import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/rxjs/internal/Observable").Observable<import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/@datorama/akita/src/plugins/paginator/paginator-plugin").PaginationResponse<Business>>;
    add(entity: Business): import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/rxjs/internal/Observable").Observable<any>;
    update(entity: Business): import("../../../../../../../../../Volumes/TINNAKORNC/wip/web/smartbiz/node_modules/rxjs/internal/Observable").Observable<any>;
    replace(entity: Business): void;
    remove(entity: Business): void;
}

问题 请帮助我,这个问题的原因是什么?我在 Mac 上创建库并希望将库分发到任何 Windows 或其他计算机,他们看不到上面代码的路径(嵌入 Mac 的路径)。谢谢

标签: angularangular-akita

解决方案


推荐阅读