-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS2.0.0@beta Conflicting library definitions for 'node' found: Winston vs. Express #10250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually I found some more interesting stuff. I already wasted a day on build debugging this and I don't have a clear solution but a workaround. (Plus other nasty things like npm links...) Here's what I got anyway. In a certain case the My workaround was referring to the Nevertheless, the upper issue still exists. |
@RyanCavanaugh I thought the issue of environmental typings being dependencies was going to be fixed? I can move that discussion into the types publisher though. |
The desired fix is the one @igabesz did -- An underlying problem is that we shouldn't be publishing packages pointing to arbitrary versions of |
Just to sum it up. Starting from an empty directory:
app.ts
tsconfig.json
And now the build: I get the same error after explicitely Now comes the ✨, modifying tsconfig.json, excluding node_modules dir, yet reincluding the preferred node typings. Watch out for the precedence of
And tadaam, And now if I Honestly, I don't understand it but I can get used to it... |
@RyanCavanaugh A simple solution would be to use |
@blakeembrey You can repeat the steps listed above to double-check. Note that generally using different versions of the same package wouldn't mean any problem, npm 3 starts creating sub- PeerDeps would worth a try. But then you have to install additional peerDeps manually for a single |
You would install one I know how NPM works, I was trying to deconstruct how TypeScript resolves here because two dependencies do exactly that - they end up on the same level when they are compatible and if they are incompatible only one will end up on the top-level while one will end up in a sub-module. This is because in the case of three, it's more efficient to de-dupe by putting the version two are compatible at the top level and making the one incompatible version a sub-module. By the following logic, it means TypeScript resolution will break if it's following the reasoning I've inferred from @RyanCavanaugh's comment above (that installing to the top-level will make that one take precedence). Edit: If it is purely globals that resolve this way, then yes, my comments are invalid and shouldn't be considered. Haven't had a chance to re-create this use-case myself to test myself of having nested duplicate dependencies at different levels. |
@igabesz what version of tsc and what version of npm are you using? i am unable to get a repro for this issue. locally node@6.0.34 is installed at the top level, so this breaks the conflict. here is my repro: c:\test\10250>ls
[.] [..] app.ts tsconfig.json
c:\test\10250>type app.ts
import * as express from 'express';
import * as winston from 'winston';
c:\test\10250>type tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs" }
}
c:\test\10250>npm -v
3.10.3
c:\test\10250>npm i @types/express @types/winston
c:\test\10250
+-- @types/express@4.0.30
| +-- @types/express-serve-static-core@4.0.31
| | `-- @types/node@6.0.34
| `-- @types/serve-static@1.7.28
| `-- @types/mime@0.0.28
`-- @types/winston@0.0.27
`-- @types/node@4.0.30
c:\test\10250>tsc -v
Version 2.1.0-dev.20160815
c:\test\10250>tsc --listFiles
C:/Users/mhegazy/AppData/Roaming/npm/node_modules/typescript/lib/lib.es6.d.ts
c:/test/10250/node_modules/@types/node/index.d.ts
c:/test/10250/node_modules/@types/express-serve-static-core/index.d.ts C:/test/10250/node_modules/@types/mime/index.d.ts
c:/test/10250/node_modules/@types/serve-static/index.d.ts
C:/test/10250/node_modules/@types/express/index.d.ts
C:/test/10250/node_modules/@types/winston/index.d.ts
c:/test/10250/app.ts |
Here's an attempt to explain what our behavior is. Let's say you have this structure in
If If both The way to get out of the 'conflict' state is to locally add a definition of
Now when |
@mhegazy My original setup was this:
NPM update plus clearing-reinstalling
For me, @RyanCavanaugh Thanks for this info. I haven't heard about |
TypeScript Version: 2.0.0@beta
Similar issue to #9494: conflict in Node library definitions. Got the following error for
tsc
:TS file
Express uses `@types/node@6.0.*1, while Winston uses 4.?.?.
Note that the build fails if I import both of these modules within the same file. I don't need to use anything from them; these 2 lines make the build fail.
package.json dependencies
In #9494 @mhegazy mentions using
@types/express@4.0.28-alpha
but that doesn't work in this case.Expected behavior:
The build should work even if there are 2 imports in the same file, and the 2 imports use separate node definition versions.
Actual behavior:
See the error above.
The text was updated successfully, but these errors were encountered: