Skip to content

Commit 55e0ce2

Browse files
authored
[UG] Give guidance on what to do on "failed to load modules" error (#2117)
1 parent 399457b commit 55e0ce2

2 files changed

Lines changed: 39 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ For the full list of changes, see the [0.8.0] release notes.
155155

156156
**Breaking changes**:
157157

158-
- Docsy is packaged as a **single Hugo module** ([#1120]).
159-
- For details, see [Use Docsy as a Hugo Module].
160-
- **Important**: non-Hugo-module projects should read the [Docsy NPM install
161-
side-effect] note.
158+
- Docsy is packaged as a **single Hugo module** ([#1120]). For details, see [Use
159+
Docsy as a Hugo Module].
160+
- **Important**: non-Hugo-module projects should be aware of the [Docsy
161+
NPM install side-effect]. Also, for guidance on Hugo-reported "failed to load modules"
162+
error, see [Docsy as an NPM package].
162163
- **Page feedback**, or [User feedback]:
163164
- In support of projects configuring analytics outside of Docsy, feedback
164165
functionality is enabled regardless of whether
@@ -177,6 +178,8 @@ For the full list of changes, see the [0.8.0] release notes.
177178
[#1726]: https://github.com/google/docsy/pull/1726
178179
[#1727]: https://github.com/google/docsy/pull/1727
179180
[0.8.0]: https://github.com/google/docsy/releases/v0.8.0
181+
[Docsy as an NPM package]:
182+
http://localhost:1313/docs/get-started/other-options/#option-3-docsy-as-an-npm-package
180183
[Docsy NPM install side-effect]:
181184
https://docsy.dev/docs/get-started/other-options/#docsy-npm-install-side-effect
182185
[Use Docsy as a Hugo Module]:

userguide/content/en/docs/get-started/other-options.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ The following shows you how to install Hugo from the release page:
6666
3. Download the latest extended version
6767
(`hugo_extended_0.9X_Linux-64bit.tar.gz`).
6868
4. Create a new directory:
69+
6970
```sh
7071
mkdir hugo
7172
```
7273

7374
5. Extract the files you downloaded to `hugo`.
7475

7576
6. Switch to your new directory:
77+
7678
```sh
7779
cd hugo
7880
```
@@ -105,9 +107,8 @@ If you have Node installed already, check your version of Node. For example:
105107
node -v
106108
```
107109

108-
Install or upgrade your version of Node to the **active [LTS release][]**. We
109-
recommend using **[nvm][]** to manage your Node installation (Linux command
110-
shown):
110+
Install or upgrade your version of Node to the **active [LTS release][]**. We recommend
111+
using **[nvm][]** to manage your Node installation (Linux command shown):
111112

112113
```sh
113114
nvm install --lts
@@ -122,9 +123,8 @@ To build or update your site's CSS resources, you'll also need
122123
{{% alert title="IMPORTANT: Check your Node version" color="warning" %}}
123124

124125
The PostCSS package installed by some older versions of Node is incompatible
125-
with Docsy. Check your version of Node against the **active [LTS release][]**
126-
and upgrade, if necessary. For details, see [Node: Get the latest LTS
127-
release][latest-lts].
126+
with Docsy. Check your version of Node against the **active [LTS release][]** and
127+
upgrade, if necessary. For details, see [Node: Get the latest LTS release][latest-lts].
128128

129129
[lts release]: https://nodejs.org/en/about/releases/
130130
[latest-lts]: #node-get-the-latest-lts-release
@@ -169,8 +169,8 @@ your project's root directory:
169169
git checkout v{{% param version %}}
170170
```
171171
172-
To work from the development version of Docsy (not recommended),
173-
run the following command instead:
172+
To work from the development version of Docsy (_not recommended_), run the
173+
following command instead:
174174
175175
```sh
176176
git submodule add --depth 1 https://github.com/google/docsy.git themes/docsy
@@ -182,9 +182,9 @@ your project's root directory:
182182
echo 'theme: docsy' >> hugo.yaml
183183
```
184184
185-
{{% alert title="Tip" %}}
186-
In Hugo 0.110.0 the default config base filename was changed to `hugo.*` from `config.*`.
187-
If you are using hugo 0.110 or above, consider renaming your `config.*` to `hugo.*`!
185+
{{% alert title="Tip" %}}As of Hugo 0.110.0, the default config base
186+
filename was changed to `hugo.*` from `config.*`. If you are using hugo
187+
0.110 or above, consider renaming your `config.*` to `hugo.*`.
188188
{{% /alert %}}
189189
190190
3. Get Docsy dependencies:
@@ -242,8 +242,8 @@ npm install
242242
> **Important**: read the [Docsy NPM install side-effect] note.
243243

244244
To work from the development version of Docsy (not recommended unless, for
245-
example, you plan to upstream changes to Docsy), omit the `-b v{{% param version
246-
%}}` argument from the clone command above.
245+
example, you plan to upstream changes to Docsy), omit the
246+
`-b v{{% param version %}}` argument from the clone command above.
247247

248248
Then consider setting up an NPM [prepare][] script, as documented in Option 1.
249249

@@ -260,7 +260,7 @@ You can use Docsy as an NPM module as follows:
260260
```sh
261261
hugo new site --format yaml myproject
262262
cd myproject
263-
echo 'theme: docsy' >> hugo.yaml
263+
echo "theme: docsy\nthemesDir: node_modules" >> hugo.yaml
264264
```
265265

266266
2. Install Docsy, and postCSS (as [instructed earlier](#install-postcss)):
@@ -276,18 +276,28 @@ You can use Docsy as an NPM module as follows:
276276
path to the Docsy theme files. For example, build your site as follows:
277277

278278
```console
279-
$ hugo --themesDir node_modules
279+
$ hugo
280280
Start building sites …
281281
...
282-
Total in 1890 ms
283282
```
284283

285-
You can drop the `--themesDir ...` flag by adding the themes directory to
286-
your site's configuration file:
284+
{{% alert title="Error: failed to load modules" color="warning" %}}
287285

288-
```sh
289-
echo 'themesDir: node_modules' >> hugo.yaml
290-
```
286+
If Hugo reports the following error when building your site ([#2116]):
287+
288+
```
289+
Error: failed to load modules: module "github.com/FortAwesome/Font-Awesome" not found in ".../myproject/node_modules/github.com/FortAwesome/Font-Awesome" ...
290+
```
291+
292+
Then run the following command and try again:
293+
294+
```sh
295+
npm rebuild
296+
```
297+
298+
[#2116]: https://github.com/google/docsy/issues/2116
299+
300+
{{% /alert %}}
291301

292302
As an alternative to specifying a `themesDir`, on some platforms, you can
293303
instead create a symbolic link to the Docsy theme directory as follows (Linux
@@ -312,8 +322,7 @@ $ ls themes
312322
docsy github.com
313323
```
314324

315-
This is a workaround necessary to support Docsy's use as a single [Hugo module]
316-
([#1120]).
325+
This is a workaround necessary to support Docsy's use as a single [Hugo module] ([#1120]).
317326
318327
[#1120]: https://github.com/google/docsy/issues/1120
319328
[0.8.0]: https://github.com/google/docsy/blob/main/CHANGELOG.md/#080

0 commit comments

Comments
 (0)