Skip to content

Commit

Permalink
Updates to UnableToResolveError to account for different platforms.
Browse files Browse the repository at this point in the history
This error message is confusing when you get it on a mac, as /tmp/ isn't the
tmp directory that is being used.  The message should probably try to account
for settings that are configured by users as well, the Metro Bundler cache at
least is something that can be overwritten.
  • Loading branch information
gdborton committed Sep 26, 2018
1 parent 73dd5e8 commit 115d915
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
const Resolver = require('metro-resolver');

const invariant = require('fbjs/lib/invariant');
const os = require('os');
const path = require('path');
const util = require('util');

Expand Down Expand Up @@ -175,6 +176,14 @@ class ModuleResolver<TModule: Moduleish, TPackage: Packageish> {
.concat(extraPaths);

const hint = displayDirPaths.length ? ' or in these directories:' : '';
const metroCacheLocation = path.join(
os.tmpdir(),
'metro-bundler-cache-*',
);
const hasteCacheLocation = path.join(
os.tmpdir(),
'haste-map-react-native-packager-*',
);
throw new UnableToResolveError(
fromModule.path,
moduleName,
Expand All @@ -186,8 +195,8 @@ class ModuleResolver<TModule: Moduleish, TPackage: Packageish> {
'To resolve try the following:',
' 1. Clear watchman watches: `watchman watch-del-all`.',
' 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.',
' 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.',
' 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.',
` 3. Reset Metro Bundler cache: \`rm -rf ${metroCacheLocation}\` or \`npm start -- --reset-cache\`.`,
` 4. Remove haste cache: \`rm -rf ${hasteCacheLocation}\`.`,
].join('\n'),
);
}
Expand Down

0 comments on commit 115d915

Please sign in to comment.