question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EEXIST: file already exists | @ngx-cache

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  <!-- Please check the repository for a similar issue or PR before submitting -->
[ ] Support request => <!-- Please check the repository for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request

Current behavior

When running in production SSR mode, ngx-cache fails on second load. It looks like it tries to create the .cache folder twice, and fails:

Error: EEXIST: file already exists, mkdir '/Users/foo/bar/.cache'
    at Object.fs.mkdirSync (fs.js:874:3)
    at new FsStorageService (/Users/foo/bar/node_modules/@ngx-cache/fs-storage/bundles/ngx-cache-fs-storage.umd.js:131:20)
    at _createClass (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20740:24)
    at _createProviderInstance (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20712:30)
    at resolveNgModuleDep (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20676:25)
    at NgModuleRef_.get (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:21384:20)
    at new FsCacheService (/Users/foo/bar/node_modules/@ngx-cache/platform-server/bundles/ngx-cache-platform-server.umd.js:41:39)
    at _createClass (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20742:24)
    at _createProviderInstance (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20712:30)
    at resolveNgModuleDep (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20676:25)

Expected/desired behavior

The expectation is that the cache services should check to see if the folder exists before trying to recreate it. This error breaks everything and shows in the browser.

Minimal reproduction of the problem with instructions

  1. Checkout the latest ng-seed/universal.
  2. Use npm run start:ssr:prod to start on localhost:4000

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

4reactions
meatflycommented, Feb 20, 2019

there is bug in XpFsStorageService use if (!stat.isDirectory()) { not if (!stat.hasOwnProperty('isDirectory')) {

workaround can by done by own implementation of storageService https://gist.github.com/meatfly/baff02d8004802a870b77171f0b3f6e0

and than use in app.server.module.ts

   ServerCacheModule.forRoot([
      {
        provide: CACHE,
        useClass: FsCacheService
      },
      {
        provide: STORAGE,
        useClass: XpFsStorageService
0reactions
squelixcommented, May 9, 2019

I still have this error

Error: EEXIST: file already exists, mkdir '/usr/src/app/.cache'
    at Object.mkdirSync (fs.js:752:3)
    at new XpFsStorageService (/usr/src/app/dist/server.js:4438:18)
    at _createClass (/usr/src/app/dist/server.js:90200:20)
    at _createProviderInstance (/usr/src/app/dist/server.js:90172:26)
    at resolveNgModuleDep (/usr/src/app/dist/server.js:90136:21)
    at NgModuleRef_../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (/usr/src/app/dist/server.js:90844:16)
    at new FsCacheService (/usr/src/app/dist/server.js:123492:35)
    at _createClass (/usr/src/app/dist/server.js:90202:20)
    at _createProviderInstance (/usr/src/app/dist/server.js:90172:26)
    at resolveNgModuleDep (/usr/src/app/dist/server.js:90136:21)

Event with your XpFsStorageService 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

EEXIST: file already exists | @ngx-cache · Issue #631 - GitHub
The expectation is that the cache services should check to see if the folder exists before trying to recreate it. This error breaks...
Read more >
Angular CLI ng new error EEXIST: file already exists Windows ...
I have uninstalled and re-installed NodeJS and npm and angular CLI. I have force cleared my npm cache (npm cache clear --force); I...
Read more >
docker npm err! tracker "idealtree" already exists - You.com
Tracker "idealTree" already exists while creating the Docker image for Node project ... clear the cache and do a npm i again with...
Read more >
Unable to setup stencil-cli - BigCommerce Support
EEXIST : file already exists, cmd shim 'C:\Users\junaidahmed\AppData\Roaming\npm\node_modules\@bigcommerce\stencil-cli\bin\stencil' ...
Read more >
Sep 09 2019 07:42 UTC - angular/angular - Gitter
So I clone clean source from ngx-admin and put my code one by one until ... An unhandled exception occurred: EEXIST: file already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found