简体   繁体   English

d.ts文件找不到模块“ rxjs / Observable”

[英]d.ts files cannot find module 'rxjs/Observable'

I am pretty new to Angular2/4 and i am trying to build a WebAPI that updates a SQL table. 我是Angular2 / 4的新手,我正在尝试构建可更新SQL表的WebAPI。 The Issue is that when I run the Build function in Visual Studio 2015, I get error code TS2307 "Cannot find module 'rxjs/Observable'" for every one of the "d.ts" files. 问题是,当我在Visual Studio 2015中运行Build函数时,对于每个“ d.ts”文件,都会收到错误代码TS2307“找不到模块'rxjs / Observable'”。 When I click on the error, it sends me to the Import statement in the Specified file, with the error under the "@rxjs/Observable" portion. 当我单击错误时,它会将我发送到指定文件中的Import语句,并且该错误位于“ @ rxjs / Observable”部分下。

I have looked for a couple hours trying to find a solution and haven't found one that matches the situation, so if I duplicated something please drop a link in the comments so I can check it out. 我已经找了几个小时试图找到解决方案,但没有找到与情况相符的解决方案,因此,如果我重复了某些事情,请在评论中添加链接,以便我进行检查。

If there are any other files you would need to help please let me know. 如果还有其他文件需要帮助,请告诉我。 Thank you in advance. 先感谢您。

Here are some(as many as I could get in the screenshot)of the errors from VS15: 以下是VS15中的一些错误(在屏幕截图中可以找到): 错误屏幕截图 Here is my Package.json file: 这是我的Package.json文件:

   {
     "version": "1.0.0",
     "name": "asp.net",
     "private": true,
     "scripts": {
           "build": "webpack",
           "start": "static ."
           },
     "dependencies": {
           "@angular/core": "2.4.0",
           "@angular/common": "2.4.0",
           "@angular/compiler": "2.4.0",
           "@angular/platform-browser": "2.4.0",
           "@angular/platform-browser-dynamic": "2.4.0",
           "core-js": "^2.4.1",
           "zone.js": "^0.8.4",
           "rxjs": "^5.2.0",
           "reflect-metadata": "^0.1.10"
           },
     "devDependencies": {
          "gulp": "^3.9.1",
          "gulp-exec": "^2.1.3",
          "awesome-typescript-loader": "^3.1.2",
          "typings": "^2.1.0",
          "webpack": "^3.8.1",
          "ng2-bs3-modal": "0.10.4"
          }
      }

Here is my tsconfig.json 这是我的tsconfig.json

  {
   "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [ "es2015", "dom" ],
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true
        }
   }

UPDATE:1 I went through and lowered the angular version number in the package.json file as shown above. 更新:1我仔细检查并降低了package.json文件中的有角版本号,如上所示。 Then deleted the node_module from the project and restarted VS15. 然后从项目中删除node_module并重新启动VS15。 then I restored the packages to find a bunch more errors waiting. 然后我恢复了软件包,以发现更多错误等待。

新错误 So I am hoping the new batch of errors helps figure something out... 因此,我希望新一批的错误能够帮助您解决问题...

On the advice of @yms , I found the Quickstart file for the Angular2.4 and copied the package.json, tsconfig.jason and systemjs.config.js into the solution. 上的建议@yms ,我找到了快速入门文件Angular2.4和复制的package.json,tsconfig.jason和systemjs.config.js到溶液中。 then i read the ReadMe file which points out that you have to use the angular/cli from now on.. so i tried installing that with the command: 然后我阅读了ReadMe文件,该文件指出您从现在起必须使用angular / cli。.所以我尝试使用以下命令进行安装:

npm install -g @angular/cli

my errors i was getting reduced to "incorrectly extends" error, which was fixed by pushing the typescript version to "^2.4.0" and the rxjs version to "5.4.2" in the package.json file then restoring the packages. 我的错误被减少为“错误地扩展”错误,此错误已通过在package.json文件中将打字稿版本推送至“ ^ 2.4.0”和将rxjs版本推送至“ 5.4.2”而得到修复,然后恢复了软件包。

So here is my working Package.json: 这是我的工作Package.json:

{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented 
with testing support",
"scripts": {
  "build": "tsc -p src/",
  "build:watch": "tsc -p src/ -w",
  "build:e2e": "tsc -p e2e/",
  "serve": "lite-server -c=bs-config.json",
  "serve:e2e": "lite-server -c=bs-config.e2e.json",
  "prestart": "npm run build",
  "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
  "pree2e": "npm run build:e2e",
  "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-
   others --success first",
  "preprotractor": "webdriver-manager update",
  "protractor": "protractor protractor.config.js",
  "pretest": "npm run build",
  "test": "concurrently \"npm run build:watch\" \"karma start 
  karma.conf.js\"",
  "pretest:once": "npm run build",
  "test:once": "karma start karma.conf.js --single-run",
  "lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
  "@angular/common": "~2.4.0",
  "@angular/compiler": "~2.4.0",
  "@angular/core": "~2.4.0",
  "@angular/forms": "~2.4.0",
  "@angular/http": "~2.4.0",
  "@angular/platform-browser": "~2.4.0",
  "@angular/platform-browser-dynamic": "~2.4.0",
  "@angular/router": "~3.4.0",
  "angular-in-memory-web-api": "~0.2.4",
  "systemjs": "0.19.40",
  "core-js": "^2.4.1",
  "rxjs": "5.4.2",
  "zone.js": "^0.7.4"
},
"devDependencies": {
  "concurrently": "^3.2.0",
  "lite-server": "^2.2.2",
  "typescript": "^2.4.0",
  "canonical-path": "0.0.2",
  "tslint": "^3.15.1",
  "lodash": "^4.16.4",
  "jasmine-core": "~2.4.1",
  "karma": "^1.3.0",
  "karma-chrome-launcher": "^2.0.0",
  "karma-cli": "^1.0.1",
  "karma-jasmine": "^1.0.2",
  "karma-jasmine-html-reporter": "^0.2.2",
  "protractor": "~4.0.14",
  "rimraf": "^2.5.4",
  "@types/node": "^6.0.46",
  "@types/jasmine": "2.5.36"
},
"repository": {}
}

对于MAC,我可以通过以下方法解决此问题:

sudo npm install -g --unsafe-perm --verbose @angular/cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块“ rxjs / internal / Observable” - Cannot find module 'rxjs/internal/Observable' 找不到模块“rxjs-compat/Observable” - Cannot find module 'rxjs-compat/Observable' RxJS6(角度 6)- node_modules/rxjs/Rx.d.ts(1,15) 中的错误:错误 TS2307:找不到模块“rxjs-compat” - RxJS6 (angular 6) - ERROR in node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat' d.ts文件中的Typescript迁移名称空间 - Typescript megring namespaces in d.ts files 获取Angular 2 .ts文件而不是.d.ts文件 - Get Angular 2 .ts files instead of .d.ts files 构建:'(' 预期在 *.d.ts 文件中。无法编译 TypeScript 项目 - Build: '(' expected in *.d.ts files. Cannot compile TypeScript project 使用Awesome Typescript Loader处理.d.ts文件 - handling .d.ts files with Awesome Typescript Loader 关于angular2-jwt的错误,找不到模块'rxjs-compat / Observable(此模块在Angular 6中不起作用) - error about angular2-jwt, Cannot find module 'rxjs-compat/Observable (this module not works in Angular 6) 在哪里可以找到Amazon Cognito Identity SDK的类型定义文件(* .d.ts),以及如何使用它们 - Where can i find Type Definitions Files (*.d.ts) for Amazon Cognito Identity SDK and how can i used them 在 program.d.ts 中找不到模块“路径” - Cannot find module 'path' in program.d.ts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM