Angular 未找到模块:错误:Can';t解决';财政司司长';有棱角的
我在angular应用程序中实现,并执行以下操作 将css添加到angular-cli.json中Angular 未找到模块:错误:Can';t解决';财政司司长';有棱角的,angular,mapbox,package.json,mapbox-gl,mapbox-gl-draw,Angular,Mapbox,Package.json,Mapbox Gl,Mapbox Gl Draw,我在angular应用程序中实现,并执行以下操作 将css添加到angular-cli.json中 。/node_modules/@mapbox/mapbox gl draw/dist/mapbox gl draw.css“ 组件 import { Component } from '@angular/core'; import * as mapboxgl from 'mapbox-gl'; import * as MapboxDraw from '@mapbox/mapbox-gl-draw'
。/node_modules/@mapbox/mapbox gl draw/dist/mapbox gl draw.css“
组件
import { Component } from '@angular/core';
import * as mapboxgl from 'mapbox-gl';
import * as MapboxDraw from '@mapbox/mapbox-gl-draw';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
static t;
ngOnInit() {
mapboxgl.accessToken = 'Token';
AppComponent.t.map= new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
zoom: 5,
center: [-78.880453, 42.897852]
});
const draw = new MapboxDraw({
displayControlsDefault: false,
controls: {
polygon: true,
trash: true
}
});
AppComponent.t.map.addControl(draw);
}
}
它的显示无法编译
/node\u模块/jsonlint行/lib/jsonlint.js
未找到模块:错误:无法解析“C:\angular\mapboxdemo\node\U modules\jsonlint lines\lib”中的“fs”
下面是我的包。json
{
"name": "mapboxdemo",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/cli": "^1.7.4",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@mapbox/mapbox-gl-draw": "^1.0.9",
"core-js": "^2.5.4",
"mapbox-gl": "^0.46.0",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.8",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
},
"browser": {
"fs": false,
"path": false,
"os": false
}
}
我试图执行ng eject
命令来生成webpack.config文件,并试图添加{fs:“empty”},但抛出以下错误
如何修复此问题?打开
package.json
文件,将其添加到浏览器对象中
"browser": {
"fs": false,
"path": false,
"os": false}
如果要在客户端使用模块,则应使用浏览器字段而不是主字段。这有助于提示用户它可能依赖于Node.js模块中不可用的原语
来源:您是否正在使用webpack?如果是,请将以下内容添加到配置中。节点:{fs:“空”}否。。我没有使用。我使用angular cli进行设置您可以发布包的内容吗?json?@EricYang i postedAdding“browser”:{“fs”:false}在package.json中解决了这个问题。我尝试将上述浏览器对象添加到package.json中,但没有成功!