typescript 错误 TS2687:'observable' 的所有声明必须具有相同的修饰符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50639530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error TS2687: All declarations of 'observable' must have identical modifiers
提问by Kay
I have an Angualr 6 project and im trying to run the following command npm run build
. How the below error message appears.
我有一个 Angualr 6 项目,我正在尝试运行以下命令npm run build
。以下错误消息是如何出现的。
ERROR in node_modules/rxjs/internal/symbol/observable.d.ts(4,9): error TS2687: All declarations of 'observable' must have identical modifiers.
node_modules/@types/node/index.d.ts(167,14): error TS2687: All declarations of 'observable' must have identical modifiers.
Angular Version
角度版本
Angular CLI: 6.0.0
Node: 9.8.0
OS: darwin x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, material, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.6.0
@angular-devkit/build-optimizer 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0 (cli-only)
@angular/flex-layout 6.0.0-beta.15
@ngtools/webpack 6.0.0
@schematics/angular 0.6.0 (cli-only)
@schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
Forgot to mention is only happening in my docker image.
忘了提及只发生在我的 docker 镜像中。
docker build -t $IMG --build-arg env=production .
# Stage 0 - Pre-requisite: Based On Node.js to BUILD and compile Demo Angular App.
FROM node:8.11.2 as node
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY ./ /app/
ARG env
RUN npm run build -- --configuration $env
# Stage 1 - Based On Nginx to have ONLY a compiled and PRODUCTION ready build.
FROM nginx:1.14
COPY --from=node /app/dist/ /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
回答by Paul
Had the same issue after updating @types/node to 10.3.0. After downgrading to version 10.1.4 everything is working again. I think rxjs has to be updated to work with the newest @types/node version. So at the moment, just use the older version:
将@types/node 更新到 10.3.0 后遇到了同样的问题。降级到 10.1.4 版后,一切又恢复正常了。我认为必须更新 rxjs 才能使用最新的 @types/node 版本。所以目前,只需使用旧版本:
npm install @types/[email protected]
UPDATE: The fix on RxJS is already done -> https://github.com/ReactiveX/rxjs/pull/3773. Now they just have to merge the changes and publish the new version.
更新:RxJS 的修复已经完成 -> https://github.com/ReactiveX/rxjs/pull/3773。现在他们只需要合并更改并发布新版本。