Skip to content

Commit 8c2752a

Browse files
committed
minor #940 Clarify missing css file error message (Gadgetdude)
This PR was squashed before being merged into the main branch. Discussion ---------- Clarify missing css file error message As a new user I came across a very confusing error message which took me way too long to debug. I was trying to set up the new webpack-encore configuration to use the `twig-loader`. I followed all the instructions, but I kept getting the following error: ``` ./node_modules/twig/twig.js contains a reference to the file path. This file can not be found, please check it for typos or update it if the file got moved. ``` Since "file path" is a very commonly used phrased, I did not realise that it meant that the file (or dependency) `path` was missing. Searching online also didn't help me out. I'm not sure what the best solution is (or if it's an accepted edge case), but having it highlighted could save some new users a lot of time and frustration when starting out. I decided on simple quotes since that works regardless of colours are enabled in the terminal. Commits ------- 897c107 Clarify missing css file error message
2 parents 1684a5a + 897c107 commit 8c2752a

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/friendly-errors/formatters/missing-css-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function formatErrors(errors) {
2222
chalk.red('Module build failed: Module not found:')
2323
);
2424
for (let error of errors) {
25-
messages.push(`${error.file} contains a reference to the file ${error.ref}.`);
25+
messages.push(`"${error.file}" contains a reference to the file "${error.ref}".`);
2626
messages.push('This file can not be found, please check it for typos or update it if the file got moved.');
2727
messages.push('');
2828
}

lib/friendly-errors/formatters/missing-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function formatErrors(errors) {
5050
if (error.loaderName) {
5151
messages.push(`${chalk.bgGreen.black('', 'FIX', '')} To ${loaderFeatures.getFeatureDescription(error.loaderName)}:`);
5252
} else {
53-
messages.push(`${chalk.bgGreen.black('', 'FIX', '')} To load ${error.file}:`);
53+
messages.push(`${chalk.bgGreen.black('', 'FIX', '')} To load "${error.file}":`);
5454
}
5555

5656
let index = 0;

test/friendly-errors/formatters/missing-css-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('formatters/missing-css-file', () => {
3939
};
4040

4141
const actualErrors = formatter([error]);
42-
expect(JSON.stringify(actualErrors)).to.contain('/some/file.css contains a reference to the file ../images/foo.png');
42+
expect(JSON.stringify(actualErrors)).to.contain('\\"/some/file.css\\" contains a reference to the file \\"../images/foo.png\\"');
4343
expect(JSON.stringify(actualErrors)).to.contain('This file can not be found, please check it for typos or update it if the file got moved.');
4444
// all needed packages will be present when running tests
4545
expect(JSON.stringify(actualErrors)).to.not.contain('yarn add');

test/friendly-errors/formatters/missing-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('formatters/missing-loader', () => {
5252
};
5353

5454
const actualErrors = formatter([error]);
55-
expect(JSON.stringify(actualErrors)).to.contain('To load /some/file.jpg');
55+
expect(JSON.stringify(actualErrors)).to.contain('To load \\"/some/file.jpg\\"');
5656
expect(JSON.stringify(actualErrors)).to.contain('You may need to install and configure a special loader');
5757
});
5858

0 commit comments

Comments
 (0)