Istanbul: No such file or directory (istanbul-reports/lib/html/assets)

Created on 2 Jan 2017  路  10Comments  路  Source: gotwarlost/istanbul

[Bug]

Hi there, when I'm using the test-coverage of Jest (so basically Istanbul), I get this error stack:

Failed to write coverage reports:
        ERROR: Error: ENOENT: no such file or directory, scandir '{path}/node_modules/istanbul-reports/lib/html/assets'
        STACK: Error: ENOENT: no such file or directory, scandir '{path}/node_modules/istanbul-reports/lib/html/assets'
    at Object.fs.readdirSync (fs.js:870:18)
    at copyAssets ({path}/node_modules/istanbul-reports/lib/html/index.js:156:16)
    at {path}/node_modules/istanbul-reports/lib/html/index.js:173:9
    at Array.forEach (native)
    at HtmlReport.onStart ({path}/node_modules/istanbul-reports/lib/html/index.js:172:21)
    at LcovReport.(anonymous function) [as onStart] ({path}/node_modules/istanbul-reports/lib/lcov/index.js:24:24)
    at Visitor.(anonymous function) [as onStart] ({path}/node_modules/istanbul-lib-report/lib/tree.js:34:30)
    at Tree.visit ({path}/node_modules/istanbul-lib-report/lib/tree.js:157:13)
    at {path}/node_modules/istanbul-api/lib/reporter.js:84:18
    at Array.forEach (native)

I can see there are no file or directory named assets in the html folder, do you know why ?

I'm using Jest v18.1.0. (and I can see in the changelog, Updated istanbul-api., maybe it's related ? Since I don't have the issue with Jest v18.0.0)

Most helpful comment

Yes, that worked!
rm -rf node_modules .yarnclean && yarn

All 10 comments

I've got the same issue when using karma instead of jest.

Stack:
[email protected]
[email protected]
[email protected]

Had the same issue, but only after I ran the yarn clean. Removing .yarnclean file and reinstalling all modules fixed the issue.

Yes, that worked!
rm -rf node_modules .yarnclean && yarn

Why would istanbul need to write in the node_modules directory? That seems wrong.

@pelle It's trying to read the templates in node_modules. Maybe a better message would be "Failed to create coverage reports", because at that point it is not writing anything.

As referenced here and here yarn is cleaning the assets folders in node_modules.

I just ignored the necessary folders inside the .yarnclean file (so it still cleans everything else).

# asset directories
docs
doc
website
images
assets
!istanbul-reports/lib/html/assets

Note the ! sign

I like the solution @rlecaro2 suggested. FYI, his pattern didn't work for me. Instead I had to use:

# asset directories
!nyc/node_modules/istanbul-reports/lib/html/assets

Thanks!

Thanks @rlecaro2. For me the pattern was !istanbul/lib/assets

At the moment, an exception to two places should be added.

.yarnclean file:

# asset directories
docs
doc
website
images
assets
!istanbul-reports/lib/html/assets
!istanbul-api/node_modules/istanbul-reports/lib/html/assets

Remember to remove .yarnlock after this operation and reinstall dependencies.

rm -rf node_modules
yarn install 

Yes, that worked!
rm -rf node_modules .yarnclean && yarn

The .yarnclean file is used to clean folders depending on the files you do not need, it is better is to control what should be removed, if you use istanbul-reports, you should add an exception to the .yarnclean file so that you do not delete the assets folder in this dependence.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asciidisco picture asciidisco  路  47Comments

dankohn picture dankohn  路  25Comments

lizhexia picture lizhexia  路  60Comments

gbahamondezc picture gbahamondezc  路  24Comments

schulzch picture schulzch  路  151Comments