这是我的方案
import { Component } from '@angular/core';
import { Nut } from 'nuts';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor(){
console.log(new Nut());
}
}
为了能够在本地安装,我必须在"preserveSymlinks": true
中添加到angular.json中的构建选项。
export class Nut {
public size: number;
}
ng serve
ERROR in ./node_modules/nuts/index.ts
Module build failed: Error: /Users/charliewalter/Desktop/my-project/peanuts/node_modules/nuts/index.tsis missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo .gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (/Users/charliewalter/Desktop/my-project/peanuts/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:709:23)
at plugin.done.then (/Users/charliewalter/Desktop/my-project/peanuts/node_modules/@ngtools/webpack/src/loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
ℹ 「wdm」: Failed to compile.
答案 0 :(得分:0)
你有为Angular编译npm包,因为Angular不支持从public override bool OnCreateOptionsMenu(IMenu menu)
{
// return base.OnCreateOptionsMenu(menu);
MenuInflater.Inflate(Resource.Menu.actionmenu, menu);
// var dd = menu.FindItem(Resource.Id.icon_group);
IMenuItem item = menu.FindItem(Resource.Id.ic_group);
LayerDrawable icon = item.Icon as LayerDrawable;
// LayerDrawable icon = (LayerDrawable)item.Icon;
CountDrawable badge;
Drawable reuse = icon.FindDrawableByLayerId(Resource.Id.ic_group_count);
if (reuse != null && reuse is CountDrawable)
{
badge = (CountDrawable)reuse;
}
else
{
badge = new CountDrawable(this);
}
badge.setCount("8");
badge.GetBounds=icon.Bounds;
icon.Mutate();
icon.SetDrawableByLayerId(Resource.Id.ic_group_count, badge);
return true;
}
目录之外构建。