简体   繁体   English

错误 TS1005: ';' 预期的。 Node_modules 中的 TypeScript Angular 6 For First Build 错误 rxjs

[英]Error TS1005: ';' expected. TypeScript Angular 6 For First Build error rxjs inside node_modules

I'm building my first Angular Application.我正在构建我的第一个 Angular 应用程序。 I'm creating a new Angular application using this command ng new purchase-section .我正在使用这个命令ng new purchase-section创建一个新的 Angular 应用程序。 But when I executing the application using ng serve -o I got the following error.但是当我使用ng serve -o执行应用程序时,出现以下错误。

ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' node_modules/rxjs/internal/types.d.ts(81,44) 中的错误:错误 TS1005: ';' expected.预期的。 node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' node_modules/rxjs/internal/types.d.ts(81,74): 错误 TS1005: ';' expected.预期的。 node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected. node_modules/rxjs/internal/types.d.ts(81,77): 错误 TS1109: 预期表达。

I have inspected types.d.ts as I know it is created by Angular.我已经检查了types.d.ts因为我知道它是由 Angular 创建的。 I'm not able to understand the error.我无法理解错误。 Note that after I got this error I deleted node_modules and I installed using npm install wished I got away still I got this error.请注意,在我收到此错误后,我删除了node_modules并使用npm install希望我能逃脱,但我仍然收到此错误。

Here is my package.JSON file:这是我的package.JSON文件:

{
 "name": "purchase-section",
 "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/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",
       "core-js": "^2.5.4",
       "rxjs": "^6.0.0",
        "zone.js": "^0.8.26"
       },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.6.8",
         "@angular/cli": "~6.0.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": "^4.0.0",
                 "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.4.2",
                  "ts-node": "~5.0.1",
                  "tslint": "~5.9.1",
                "typescript": "~2.7.2"
                 }
               }

I had the same issue.我遇到过同样的问题。 I investigated that rxjs released a new version: 6.4.0 .我调查了rxjs发布了一个新版本: 6.4.0 And it broke the build.它破坏了构建。 According to review , the minimum supported version of TypeScript is 2.8 .审查,TypeScript 支持的最低版本为2.8 If you don't want to update TypeScript version, just change "rxjs": "^6.0.0", to "rxjs": "6.3.3" in package.json .如果你不想更新版本打字原稿,只需改变"rxjs": "^6.0.0", to "rxjs": "6.3.3"package.json

I was facing the same issue while developing an angular6 project.我在开发 angular6 项目时遇到了同样的问题。 I spent more time finally it's working for me.我花了更多的时间终于对我有用了。

Here is the solution:这是解决方案:

  1. Open "package.json"打开“package.json”

  2. rxjs and "TypeScript" verstion like below screenshot rxjs和“TypeScript”版本如下图所示

    在此处输入图片说明

  3. Change like the below screenshot:像下面的截图一样改变:

    在此处输入图片说明

  4. Next go to your project folder and delete "node_modules" folder.接下来转到您的项目文件夹并删除“node_modules”文件夹。

  5. After delete, next run npm install in your project folder删除后,接下来在您的项目文件夹中运行npm install

  6. Finally run ng serve .最后运行ng serve It should work (I tried 3 projects and confirmed).它应该可以工作(我尝试了 3 个项目并确认)。

Just remove ^ character from "rxjs": "^6.0.0" from package.json file and make it "rxjs": "6.0.0" .只需从package.json文件中删除^字符"rxjs": "^6.0.0"并使其成为"rxjs": "6.0.0" It should work fine.它应该可以正常工作。

Today I faced the same issue.今天我遇到了同样的问题。 None of the above answers worked except a comment from one @Nasreen Ustad.除了@Nasreen Ustad 的评论外,上述答案均无效。 So what you have to do is:所以你要做的是:

  1. Go to package.json and modify "rxjs": "^6.0.0" to "rxjs": "6.0.0"转到 package.json 并将"rxjs": "^6.0.0"修改为"rxjs": "6.0.0"
  2. Run npm update in your project在你的项目中运行npm update

No need to change typescript version.(Mine: "typescript": "~2.7.2" )无需更改打字稿版本。(我的: "typescript": "~2.7.2"

进入项目目录运行: npm install rxjs@6.0.0 --save

在您的Package.json文件中,从"rxjs": "^6.0.0"删除^符号(插入符号)并添加"rxjs": "6.0.0"它将正常工作。

Step 1 : Go to package.json and modify "rxjs": "^6.0.0" to "rxjs": "6.0.0" 第1步:转到package.json并修改"rxjs": "^6.0.0""rxjs": "6.0.0"

Step 2 Run npm update in your project. 步骤2在项目中运行npm update

只需将 TypeScript 依赖版本更改为^2.8

Your package.json has following lines:您的 package.json 有以下几行:

"rxjs": "^6.0.0",

"typescript": "~2.7.2"

This tells npm to install the following versions这告诉 npm 安装以下版本

rxjs: Latest version in version 6 series which is 6.4.0 rxjs: version 6 系列的最新版本,即6.4.0

typescript: Latest patched version in minor version 2.7 which is 2.7.2打字稿:次要版本 2.7 中的最新补丁版本,即2.7.2

Now RxJS module also installs the type definition files for TypeScript.现在 RxJS 模块也安装了 TypeScript 的类型定义文件。 The type definition file included in the rxjs module that got installed in your project is not compatible with typescript version installed in the same project.安装在项目中的 rxjs 模块中包含的类型定义文件与安装在同一项目中的 typescript 版本不兼容。

So as a solution in your package.json file you can either bump up the version of Typescript to say 2.8 as因此,作为 package.json 文件中的解决方案,您可以将 Typescript 的版本提高到 2.8 作为

"typescript": "^2.8.0"

or bump down the version of ngrx to something like或者将 ngrx 的版本降低到类似

"ngrx": "~6.0.0" and "ngrx": "~6.0.0"

do a fresh npm install.做一个新的 npm 安装。

You can check the version number of the module installed by looking in following files:您可以通过查看以下文件来检查安装的模块的版本号:

node_modules/rxjs/package.json and
node_modules/typescript/package.json 

Update in package.json rxjs": "6.3.3"更新 package.json rxjs": "6.3.3"

in terminal 1. run npm update 2. run ng serve在终端 1. 运行 npm update 2. 运行 ng serve

It should compile successfully它应该编译成功

Check your typescript version with below command.使用以下命令检查您的打字稿版本。

~ tsc --version Version 3.3.3

As this is the latest typescript version, I've upgraded the project angular version to 7 by running below command in project home folder.由于这是最新的打字稿版本,我已通过在项目主文件夹中运行以下命令将项目角度版本升级到 7。 It solved the issue.它解决了这个问题。

~]# ng update @angular/cli @angular/core ~]# ng update @angular/cli @angular/core

I changed the version for rxjs and typescript.我更改了 rxjs 和 typescript 的版本。 My package.json has the following entries:我的package.json有以下条目:

"typescript": "^2.7.2"
"rxjs": "^6.3.3",

I also had to upgrade angular cli.我还必须升级 angular cli。

My current project is in asp.net MVC with angular 8. After updating the angular project from 8 to 9, the angular build working fine but facing the above problem for MVC build.我当前的项目是在 angular 8 的 asp.net MVC 中。将 angular 项目从 8 更新到 9 后,angular 构建工作正常,但面临上述 MVC 构建问题。 (on azure) (天蓝色)

Just hiding the只是隐藏

node_modules节点模块

folder, solved my problem.文件夹,解决了我的问题。

隐藏 node_modules 文件夹

Seems like your Angular and/or rxjs version is not compatible with TypeScript.似乎您的 Angular 和/或 rxjs 版本与 TypeScript 不兼容。

Remove the ~ sign in the TypeScript version, add ^ instead.删除 TypeScript 版本中的~符号,改为添加^ Then, install packages again.然后,再次安装软件包。

Try running npm start and ng build prior to ng serve .尝试在ng serve之前运行npm startng build

These two changes what you want:这两个改变你想要的:

// in package.json:

"rxjs": "^6.2.2" ==> "rxjs": "latest" "rxjs": "^6.2.2" ==> "rxjs": "latest"
"typescript": "2.7.2" ==> "typescript": "2.8" "typescript": "2.7.2" ==> "typescript": "2.8"

where ==> means to replace其中==>表示替换

I have tried all the other answers.我已经尝试了所有其他答案。 But I found issue.但我发现了问题。 I had ts lint plugin installed which forced file to be ended without space.我安装了 ts lint 插件,它强制文件在没有空间的情况下结束。 I removed it and it is working.我删除了它,它正在工作。

You can also remove the space going to that specific file.您还可以删除进入该特定文件的空间。

如果不是,您可以使用以下命令将npm版本更新为最新版本:

npm update -g

I had to uninstall and reinstall angular CLI.我不得不卸载并重新安装 angular CLI。

npm uninstall -g @angular/cli angular-cli
npm cache clean
npm install -g @angular/cli@latest
npm install -g @angular/cli@latest

Encountered this error with: rxjs/store: ^6.4.0 typescript: ~2.7.2 angular/cli ~6.0.0遇到此错误:rxjs/store: ^6.4.0 typescript: ~2.7.2 angular/cli ~6.0.0

Updated everything to the latest except rxjs rxjs/store: ^6.3.3 typescript: ~3.1.1 angular/cli ~7.0.3除了 rxjs rxjs/store: ^6.3.3 typescript: ~3.1.1 angular/cli ~7.0.3 之外的所有内容都更新到最新的

Basically I created an blank new project (ng new newProject) and installed @ngrx/store which brought down v6.3.3.基本上我创建了一个空白的新项目(ng new newProject)并安装了@ngrx/store,这导致了 v6.3.3。 This worked for me.这对我有用。

I had same error npm install typescript@2.8.0 我有同样的错误npm install typescript@2.8.0

worked for me 为我工作

进入项目目录运行:

npm install -s rxjs-compat

The below steps resolved my issue以下步骤解决了我的问题

There are two files that have to modify.有两个文件需要修改。

  • node_modules\\@ag-grid-community\\core\\dist\\cjs\\utils\\index.js node_modules\\@ag-grid-community\\core\\dist\\cjs\\utils\\index.js

//export * from "./utils"; //从“./utils”导出*;

  • node_modules\\@ag-grid-community\\core\\dist\\cjs\\utils\\index.d.ts node_modules\\@ag-grid-community\\core\\dist\\cjs\\utils\\index.d.ts

//_export(require("./utils")); //_export(require("./utils"));

comment utils as above.注释 utils 如上所述。 now npm start现在 npm 开始

暂无
暂无

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

相关问题 错误TS1005:预期为“>”。 node_modules/@tensorflow/tfjs-layers/dist/engine/training_utils.d.ts - Error TS1005: '>' expected. node_modules/@tensorflow/tfjs-layers/dist/engine/training_utils.d.ts node_modules/rxjs/internal/types.d.ts(81,44): 错误 TS1005: ';' 安装 Angular 6 后的预期错误 - node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected error after installation of Angular 6 Angular 7 node_modules/graphql-tag/lib/index.d.ts(2,57) 中的错误:错误 TS1005:“,”预期 - Angular 7 ERROR in node_modules/graphql-tag/lib/index.d.ts(2,57): error TS1005: ',' expected 如何修复 node_modules/chart.js/types/animation.d.ts(20,37) 中的错误:错误 TS1005:“,”预期。 在 chart.js 中 - How to fix ERROR in node_modules/chart.js/types/animation.d.ts(20,37): error TS1005: ',' expected. in chart.js Angular 8 Firebase 获取 node_modules/firebase/index.d.ts(4369, 38): 错误 TS1005: ';' 预期的 - Angular 8 Firebase Getting node_modules/firebase/index.d.ts(4369, 38): error TS1005: ';' expected node_modules/@types/jasmine/index.d.ts:error TS1005:'='预期 - node_modules/@types/jasmine/index.d.ts: error TS1005: '=' expected node_modules/@types/babel__traverse/index.d.ts(68,50) 中的错误:错误 TS1005: ']' 预期 - ERROR in node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected 错误:node_modules/@types/d3-dsv/index.d.ts(159,60):错误 TS1005:“,”预期 - Error: node_modules/@types/d3-dsv/index.d.ts(159,60): error TS1005: ',' expected node_modules/@types/lodash/common/array.d.ts(37,24) 中的错误:错误 TS1005:';' 预期的 - ERROR in node_modules/@types/lodash/common/array.d.ts(37,24): error TS1005: ';' expected node_modules/@firebase/firestore/dist/index.d.ts:27:28 中的错误 - 错误 TS1005:']' 预期 - ERROR in node_modules/@firebase/firestore/dist/index.d.ts:27:28 - error TS1005: ']' expected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM