Closed ChrisMBarr closed 7 years ago
I also get same problem.
is --allowjs
set? can you share the project?
Sorry, I cannot share the project, and no that flag is not set. My tsconfig.json
is above, and we just use that with VS2015 Update 3, which just triggers the build with MSBuild normally.
I have teammates complaining about the same issue happening to them on the same projects. I also work on a project at home on a different computer that has the exact same issue & the same setup (TS 2.2.1, VS2015 U3, etc.)
do you see the same behavior if you create a bare-bones project with the same configurations?
We have the same problem https://github.com/wc-catalogue/blaze-elements/issues/299 although with type definitions write access
@Hotell do you see this without "awesome-typescript-loader"? can you share repro steps with me?
yup, as you can see in the issue the output is from running raw tsc
second time.
just clone the repo https://github.com/wc-catalogue/blaze-elements
yarn
from rootyarn tsc
-> first time compilation ( everything's ok ) => first time definitions/
folder generatedyarn tsc
again -> errorsWe're having a similar issue -- same version of typescript (2.2.1) and Visual Studio 2015 (Update 3); the first time the build runs, there are zero errors, but after that we get hundreds of these errors.
It appears that all of the errors (for us) are in the "node_modules" folder, which we have set to exclude in our tsconfig.json file. -- From looking at similar bugs, it seems like the excludes aren't treated the same in this version of typescript?
Our tsconfig.json file:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"wwwroot",
"aot",
"AngularApp/main-aot.ts"
],
"compileOnSave": true
}
Some of the errors we get (they're all the same, but different files):
Severity Code Description Project File Line Suppression State
Error TS5055 Cannot write file 'C:/XYZ/Project.AppWeb/node_modules/zone.js/dist/zone.js' because it would overwrite input file. TypeScript Virtual Projects 1 Active
Error TS5055 Cannot write file 'C:/XYZ/Project.AppWeb/node_modules/events/events.js' because it would overwrite input file. TypeScript Virtual Projects 1 Active
Error TS5055 Cannot write file 'C:/XYZ/Project.AppWeb/node_modules/core-js/modules/_wks.js' because it would overwrite input file. TypeScript Virtual Projects 1 Active
Error TS5055 Cannot write file 'C:/XYZ/Project.AppWeb/node_modules/core-js/modules/_uid.js' because it would overwrite input file. TypeScript Virtual Projects 1 Active
Error TS5055 Cannot write file 'C:/XYZ/Project.AppWeb/node_modules/core-js/modules/_to-primitive.js' because it would overwrite input file. TypeScript Virtual Projects 1 Active
Again, if we delete the "node_modules" folder the build will work once, but then once it's been recreated, it will fail on the next rebuild.
@Hotell i am not seeing this locally, what am i missing?
c:\test\14538\blaze-elements>yarn tsc
yarn tsc v0.18.1
$ "c:\test\14538\blaze-elements\node_modules\.bin\tsc"
Done in 5.46s.
c:\test\14538\blaze-elements>yarn tsc
yarn tsc v0.18.1
$ "c:\test\14538\blaze-elements\node_modules\.bin\tsc"
Done in 5.87s.
c:\test\14538\blaze-elements>dir /B definitions
packages
polyfills.d.ts
styles.d.ts
test-helpers.d.ts
vendors.d.ts
c:\test\14538\blaze-elements>yarn tsc
yarn tsc v0.18.1
$ "c:\test\14538\blaze-elements\node_modules\.bin\tsc"
Done in 4.48s.
@BrainSlugs83 if you have a repro project i would love to take a look.
I am also facing the same problem, these are the errors: And this is my tsconfig.json:
Since I am not using typescript at all I just created tsconfig to skip build, I also had to choose target=ES6 otherwise I was having other errors.
is the tsconfig.json part of your project? and can you confirm the content type is "Content"? if so, can you share your project?
@mhegazy Hi, yes I can confirm tsconfig.json is included in the project:
But I am sorry I don't know what "content type" are you referring to, can you please clarify?
I can't share the project.
On my project, I can also confirm that the tsconfig file is included in the project file, and it is listed as content.
@max-favilli I think @mhegazy means the "Build Action" when talking about "content type".
Select tsconfig.json in the solution explorer. Bring up the Properties window (F4 key by default). There will be a Build Action property.
Thanks @kevindqc , @mhegazy yes "Build Action" is set to "content"
Can you share your virtual project structure with me, to get that you need to:
Tools
> Options
> Text Editor
> TypeScript
> Project
, and check Display Virtual Projects when no Solution is loaded
;TypeScript Virtual Project
@mhegazy like this?
Thanks for helping.
I have the same problem. I can't share the project either, but I will try to provide as much information as possible.
I have typescript compilation disabled in the .csproj (<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
)
Instead it is compiled by npm run build:prod
, which is in a build event.
The errors are not always there. I have been trying to make them appear (there were shown in VS, so I restarted VS). I've tried building the typescript project, building the solution, running tests, running code analysis, running code coverage, etc. Nothing triggers it. Then, just as I was writing the last sentence, the errors appeared. So it seems to be some background tasks that does it? It seems to happen around 2 minutes after I started a build (at least the 2-3 times I tried it out)
Timeline: 1:37:20 - Opened Visual Studio 1:37:30 - Started solution build 1:38:20 - Build finished 1:39:39 - Errors appeared
I noticed my project was still using the v2.0.3 Microsoft.TypeScript.Compiler
and Microsoft.TypeScript.MSBuild
nuget packages. I updated them to v2.2.1. So far, no error. Will update if I see the errors again. (Edit: I see the errors again, altough it took a bit longer, ~5 minutes, without me doing anything but building when I opened VS. Actually, I don't even need to build anything to get the error - just opening the project and waiting a few minutes shows the errors)
About those outdated nuget packages, is that normal? I think I got a popup to upgrade my project typescript tools when I installed the new version of typescript, but it seems it only updated <TypeScriptToolsVersion>2.2</TypeScriptToolsVersion>
. Should it not also update the nuget packages?
I just updated to Typescript 2.2.1 and having this same issue. Its flagging all the the node_modules but the tsc compiler completes without a problem.
@mhegazy
@Hotell i am not seeing this locally, what am i missing?
right, it was fixed by https://github.com/wc-catalogue/blaze-elements/commit/cdb94bf8feb3a1ad7e21e6fce243e3322c1334cc
sry for delayed answer and thx 4 help!
@Hotell @mhegazy Doesn't seems to work for me. Maybe it works if you have d.ts files in a "definitions" folder? But I don't have that. I have @types under "node_modules" which should be inheritedly excluded?
@chrismbarr May I ask if you got this resolved yet? I've been following the thread and even did the fix suggested by @Hotell couple of posts up but I'm still getting these Errors in Visual Studios. They all seem to be coming from the node_modules folder.
Would you be able to enable detailed logging and send us the results? Set the system environment variable TSS_LOG
to a value such as -file C:/temp/logs/tsserver.log -level verbose
(make sure the logs folder exists). Then after you repro the problem, send/attach the log for analysis. (Note: It may contain data such as file paths and completion lists, so be sure there isn't any data you don't want to share in it).
In my testing I've occasionally seen the project system construct a view of the project that contains the wrong files, causing intermittent errors at unpredictable times. I'd like to see if that may be the cause here.
I can provide my email address if you'd rather send the files direct than upload them (billti at microsoft dot com). Thanks.
@johnlee no, still the same in VS2015. However, I've since started to use Visual Studio 2017 and I have no errors in there!
@billti Variable added, visual studio (2017) restarted, solution rebuilded, but the log file is not being created. What should I check?
Is it definitely a system environment variable (i.e. if you open a new command prompt and run SET TSS
is the setting listed)? If not that, is the folder the log is to be written to already present (the logger won't create directories that don't exist). Other than that, its also safer to use forward slashes rather than backslashes in the path.
:(
@billti Ok, I just checked and the log files are there now. Please find them here attached tss-log.zip
Thanks. I took a look in that log, and I don't see that error being reported by any calls in it. Did the error definitely occur in the time frame this log covers?
@billti Yes, the errors are occurring at all times:
They are just there permanently. And refreshed on every single build.
All of those errors related to incorrect variable declarations (a separate issue we have already fixed for an upcoming release). This issue is about Cannot write file...
per the title and screen shots above. Do you not have the Cannot write file...
issue?
@billti after posting my previous message (which I left there as a demonstration of my stupidity) I realized the errors are of a different kind. I can only guess the visual studio update I installed few days ago solved the original issue. But I am not sure. I got rid of these errors from the previous message just removing the types from @types. Thanks a lot.
@billti I'm trying to have some logs to send you, but none are created. I have set TSS_LOG
to -file C:/temp/logs/tsserver.log -level verbose
in my system (not user) variables.
C:\temp\logs
exists, and I gave full control to Everyone
.
If I restart my VS2015, nothing is created inside C:\temp\logs
even after I get all my Cannot write file...
errors. If I try to type node node_modules\typescript\lib\tsserver.js
(and CTRL+C immediately) in a new command prompt, I do get two log files.
Sorry @kevindqc , I didn't realize you were on VS 2015. That logging only applies to VS 2017 (which now uses tsserver.js out of process for the language service).
Going back and looking at your issue - if you are seeing the error list randomly change, I believe that is the same issue @zhengbli just fixed in https://github.com/Microsoft/TypeScript/pull/15080 .
@billti np. I think this issue is only hapenning on VS2015, no? The only user with the problem that was using VS2017 was having different errors related to typings. Someone who switched from VS2015 to VS2017 said the problem went away.
Also, the error list doesn't randomly change - it gets populated at a random time, once, with all those "Cannot write .." errors that this issue is about. Are you sure that #15080 fixes it? I see nothing about this issue except the reference you made to it yesterday? How can I test it? I see there's a 2.3 RC but it was released 9 days ago while the fix was merged 2 days ago :(
Also I noticed the errors stay in my error list even after I close the solution.
Also the person who posted his typescript virtual project was the one with the different errors, so I imagine it wasn't helpful. Here is mine:
Is node_modules
supposed to be there? It is in my tsconfig excludes. It doesn't contain everything that my physical node_modules folder has though (14 subfolders vs 854 subfolders in my node_modules folder)
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": false,
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"baseUrl": "./src",
"skipLibCheck": true,
"paths": {
},
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"dist",
"typings"
],
"types": [
"core-js",
"jasmine",
"lodash",
"node",
"webpack"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
}
}
Haven't had the errors so far after upgrading to the TS2.3 tools. Thanks! Edit: Nop. The errors are still there after all, just took longer to appear.
Seems that this issue related with this issue. Sample solution to reproduce - uploaded.
I found a fix for me. In my case I used outDir
and rootDir
without specifying files
array. When adding the path of outDir
to the exclude
array everything seems to be working normally.
{
"compilerOptions": {
...,
"outDir": "./dist",
"rootDir": "./src",
},
"exclude": [
"node_modules",
"dist" <-- I had to add this to fix the errors
]
}
Maybe TypeScript is watching over the content of the dist
folder as well even though it's set as the outDir
.
If you have your outDir
under your project root, and you are just including everything under the root, then this would be expected. Generally you want to have your build output somewhere other than within the project source folder.
Looks like all the problems above are addressed in this thread or linked issues. Let me know if that's not the case and I'll reopen. Thanks!
@billti I assume that your comment is in response to my previous comment? If so, thanks for clarifying. This makes the matter more obvious to me now as I assumed when specifying the rootDir
the compiler will only watch that particular folder and exclude everything else. But the current behavior makes sense.
best solution is from borislemke .
{ "compilerOptions": { ..., "outDir": "./dist", "rootDir": "./src", }, "exclude": [ "node_modules", "dist" <-- I had to add this to fix the errors ] }
I ran into the same issue and found that one of my imports was incorrectly referencing the class in my dist folder E.G import {ClassName} from "../../dist/ClassName";
As the importing class was in the same folder I changed it to: import {ClassName} from "./ClassName";
and everything is compiling again :)
We had a pre-defined 'dist' folder in our app. Deleting that fixed it for me.
I think this is the underlaying problem (the last Windows Creators Update): visual-studio-2015-deletes-file-on-save-cordova-solution
Just add you "dist" folder to the exclusions list in tsconfig.json ex: "exclude": ["node_modules", "dist"]
I corrected this by adding an Include section:
"include": [ "*.ts", ], "exclude": [ "node_modules" ]
I ran in to this as well when using an outDir
which was under my sources directory.
How is it that the typescript compiler does not know by default that it should not try to compile things in the outDir
? That seems strange. Adding the outdir to the exclusion list did fix it though.
i have this problem with netbeans lol 👎
TypeScript Version: 2.2.1
When using Visual Studio 2015 Update 3 I am getting hundreds of errors in the error list like:
It looks like this all the time. It doesn't actually prevent building, and everything works just fine, but the error list is distracting and difficult to locate "real" errors when they occur.
My
tsconfig.json
fileHow can I get rid of all these errors?
(I've also posted this question on StackOverflow with no responses yet)