我想在angular-4项目上运行npm install,它给了我错误,
我的package.json是:
"devDependencies": { "@angular/compiler-cli": "^4.4.6","@angular/language-service": "^4.4.6","@compodoc/compodoc": "^1.1.6","@types/jasmine": "^2.8.3",
和
"typescript": "~2.3.3" in dependencies. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,227): ':' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,47): ';' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,104): ']' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,112): ',' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,113): Property assignment expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,121): ')' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,147): '(' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,162): ']' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,163): ',164): Property assignment expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,165): Property assignment expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,179): ',183): ':' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,208): '{' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,217): ':' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,222): ',90): '(' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,228): Expression expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,230): ')' expected. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,68): 'ReadonlyArray' only refers to a type,but is being used as a value here. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,92): The right-hand side of an arithmetic operation must be of type 'any','number' or an enum type. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,94): Cannot find name 'methodName'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,106): Cannot find name 'string'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,124): 'ReadonlyArray' only refers to a type,149): The right-hand side of an arithmetic operation must be of type 'any',150): A computed property name must be of type 'string','number','symbol',or 'any'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,151): Cannot find name 'P'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,156): Cannot find name 'keyof'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,162): Cannot find name 'T'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,180): Cannot find name 'P'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,217): Cannot find name 'T'. ERROR in /home/infinity/CiscoGit/AS/AS-BAC-BPA/node_modules/@types/jasmine/index.d.ts (138,219): Cannot find name 'P'.
您在package.json中使用以下
semver作为@ types / jasmine包:
"@types/jasmine": "^2.8.3"
^表示您的软件包安装程序将下载可用于该软件包的最新次要版本,在本例中为2.8.11. (如果您访问https://www.npmjs.com/package/@types/jasmine,您会注意到他们在20小时前发布了最新版本2.8.11.)
有两种方法可以解决您的问题:1)确保您的Typescript版本与@ types / jasmine包兼容2)将您的版本锁定到特定版本(2.8.8相当稳定).希望这可以帮助!