angular: error TS2687: All declarations of 'observable' must have identical modifiers.
I’m submitting a…
[X] Other... Please describe:
Issue with build
Current behavior
When i npm run build
my project in a docker environment i get the following error.
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.
Expected behavior
For it to build successfully, this error is stopping that.
Minimal reproduction of the problem with instructions
docker build -t demo:production --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
What is the motivation / use case for changing the behavior?
Environment
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
Browser:
- [ X] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX v9.8.0
- Platform: Mac
Others:
TS Config
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 36
- Comments: 19 (3 by maintainers)
This issue was fixed in the latest version of RxJS. Just run this command to update, then you should be able to compile your project:
npm install --save rxjs
There could be 2 solutions:
to
I would prefer the 2nd.
Fix is here. https://stackoverflow.com/questions/50639530/error-ts2687-all-declarations-of-observable-must-have-identical-modifiers
I was using
@types/node 10.3.0
i had to downgrade. Im now using@types/node": "~8.9.4"
Tested, the below works.
I fixed the problem already.
What I did:
rxjs 6.2.0
and@types/node 10.1.4
rxjs/add/observable/of
import { of } from "rxjs";
rxjs 6.2.1
and@types/node 10.5.2
Try this fix: In your package.json set this dependency >
"@types/node": "10.0.4"
> npm i > ng serve.I have still the same problem, my dependency versions are the latest:
Dup of https://github.com/ReactiveX/rxjs/issues/3769 (being tracked here https://github.com/DefinitelyTyped/DefinitelyTyped/issues/26198 mentioned in the issue), not related to angular.
@petercunha answer solve this issue for me. 👍