您好我在这里遇到此问题: Typescript Node.js最简单的设置不起作用-错误TS2307:找不到模块'fs'
而且我也尝试过该解决方案,但我无法使其正常工作
我的依赖:
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@swimlane/ngx-charts": "^6.1.0",
"core-js": "^2.4.1",
"d3": "^4.9.x",
"mobx": "^3.3.1",
"mobx-angular": "^2.0.0",
"mobx-remotedev": "^0.2.8",
"rxjs": "^5.0.1",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.4.1",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^9.4.0",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1", …Run Code Online (Sandbox Code Playgroud) 我已经在Windows 64位中安装了node.js,并且在本地项目上运行gulp时遇到了这个问题。
另一个注意事项:npm install与packages.json配合良好
Error: Cannot find module 'lodash.assign'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\NBCredit_FRTE\RelyToolsSln\RelyTools.Web\node_modules\gulp-jshint\node_modules\lodash.clone\node_modules\lodash._baseclone\index.js:9:14)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
PS D:\NBCredit_FRTE\RelyToolsSln\RelyTools.Web>
Run Code Online (Sandbox Code Playgroud)
这是我的package.json(我正在尝试设置此项目:https : //github.com/MarlabsInc/webapi-angularjs-spa)
{
"name": "webapi-angularjs-spa",
"description": "SPA Demo app with AngularJS",
"author": "Shiju Varghese",
"version": "0.5.0",
"repository": "https://github.com/MarlabsInc/webapi-angularjs-spa",
"devDependencies": {
"gulp-util": "~2.2.14",
"gulp": "~3.9.0",
"gulp-concat": "~2.1.7",
"gulp-uglify": "~0.2.1",
"jshint": "~2.4.3",
"gulp-jshint": "~1.4.2",
"jshint-stylish": …Run Code Online (Sandbox Code Playgroud) 由于我将代码更新为新的Rxjs 6,我不得不像这样更改拦截器代码:
auth.interceptor.ts:
...
return next.handle(req).pipe(
tap((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
// do stuff with response if you want
}
}),
catchError((error: any) => {
if (error instanceof HttpErrorResponse) {
if (error.status === 401) {
this.authService.loginRedirect();
}
return observableThrowError(this.handleError(error));
}
})
);
Run Code Online (Sandbox Code Playgroud)
而且我无法测试rxjs运算符"tap"和"catchError".
实际上我只能测试管道是否被调用:
it('should intercept and handle request', () => {
const req: any = {
clone: jasmine.createSpy('clone')
};
const next: any = {
handle: () => next,
pipe: () => next
};
spyOn(next, 'handle').and.callThrough(); …Run Code Online (Sandbox Code Playgroud)