Skip to content

Commit

Permalink
fix missing node_modules directory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 4, 2020
1 parent 0f50082 commit 09ec6b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion snowpack/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import cacache from 'cacache';
import globalCacheDir from 'cachedir';
import etag from 'etag';
import execa from 'execa';
import crypto from 'crypto';
import projectCacheDir from 'find-cache-dir';
import findUp from 'find-up';
import fs from 'fs';
Expand All @@ -25,7 +26,13 @@ export const GLOBAL_CACHE_DIR = globalCacheDir('snowpack');
export const RESOURCE_CACHE = path.join(GLOBAL_CACHE_DIR, 'pkg-cache-1.4');
export const BUILD_CACHE = path.join(GLOBAL_CACHE_DIR, 'build-cache-2.7');

export const PROJECT_CACHE_DIR = projectCacheDir({name: 'snowpack'});
export const PROJECT_CACHE_DIR =
projectCacheDir({name: 'snowpack'}) ||
// If `projectCacheDir()` is null, no node_modules directory exists.
// Use the current path (hashed) to create a cache entry in the global cache instead.
// Because this is specifically for dependencies, this fallback should rarely be used.
path.join(GLOBAL_CACHE_DIR, crypto.createHash('md5').update(process.cwd()).digest('hex'));

export const DEV_DEPENDENCIES_DIR = path.join(PROJECT_CACHE_DIR, 'dev');
const LOCKFILE_HASH_FILE = '.hash';

Expand Down

1 comment on commit 09ec6b5

@vercel
Copy link

@vercel vercel bot commented on 09ec6b5 Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.