# js.Build resolve behaviour changes in 0.78.1

**URL:** <https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265>\
**Category:** support\
**Created:** [December 28, 2020, 6:38pm UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265 "2020-12-28T18:38:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![capnfabs](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/capnfabs/32/9593_2.png) [@capnfabs](https://discourse.gohugo.io/u/capnfabs)\
**Post date:** [December 28, 2020, 6:38pm UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/1 "2020-12-28T18:38:00Z")

</div>

The JS for the [paperesque](https://github.com/capnfabs/paperesque) theme is built using Hugo’s asset processing pipeline, but it stopped building as of hugo 0.78.1. I’m not entirely sure why, and would love some help 🙂

The specific error is

> Error: Error building site: JSBUILD: failed to transform “js/main.js” (application/javascript): “/Users/fabian/Code/hugoThemes/\_script/hugoThemeSite/exampleSite2/themes/paperesque/assets/js/floatingFootnotes.js:1:31”: Could not resolve “@juggle/resize-observer” (mark it as external to exclude it from the bundle)

`@juggle/resize-observer` is listed in the `package.json` in the theme, and is has been installed into the `node_modules` directory, which is checked into the theme’s repo.

When I build the example site for the theme using:

```sh
git clone git@github.com:capnfabs/paperesque.git
cd paperesque/exampleSite
hugo serve --themesDir=../..

```

…then everything works fine, but when I try to add it to as a theme to another repo, the build fails. E.g.:

```auto
git clone git@github.com:gohugoio/hugoBasicExample.git basic-example
cd basic-example
mkdir themes && git clone git@github.com:capnfabs/paperesque.git themes/paperesque
HUGO_THEME=paperesque hugo serve

```

I think it’s got something to do with [this comment in the docs](https://gohugo.io/hugo-pipes/js/#include-dependencies-in-packagejson--node_modules):

> From Hugo `0.78.1` the start directory for resolving NPM packages (aka. packages that live inside a `node_modules` folder) is always the main project folder.

My question is, what do I need to do so that the theme can import JS installed in its `node_modules` directory again?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [December 28, 2020, 8:27pm UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/2 "2020-12-28T20:27:25Z")

</div>

> [@capnfabs](#):
>
> My question is, what do I need to do so that the theme can import JS installed in its `node_modules` directory again?

I would just drop the idea of a them having “its node\_modules”. You can use `hugo npm pack` to consolidate these NPM dependencies if needed.

---

<div class="post-metadata">

**Author:** ![capnfabs](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/capnfabs/32/9593_2.png) [@capnfabs](https://discourse.gohugo.io/u/capnfabs)\
**Post date:** [December 29, 2020, 10:44am UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/3 "2020-12-29T10:44:10Z")

</div>

Thanks @bep!

So to make sure I understand, if I want to keep using the JS Build Pipeline in the theme, my instructions to people _using_ the theme should be something like:

```auto
git clone git@github.com:capnfabs/paperesque.git themes/paperesque
hugo mod npm pack
npm install

```

Is that correct? If so, is there still a way to use Hugo to build the theme’s JS, but without theme users having to worry about NPM?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [December 29, 2020, 11:52am UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/4 "2020-12-29T11:52:37Z")

</div>

> [@capnfabs](#):
>
> Is that correct? If so, is there still a way to use Hugo to build the theme’s JS, but without theme users having to worry about NPM?

@capnfabs

I would think that you need to generate the theme’s resources and then commit them in the theme repo. Same as authors are required to do for Hugo (Go) Pipes and Modules, when submitting their theme on the Hugo Themes Showcase.

However I do not use the Hugo JS pipeline myself, since I am allergic to npm (due to past incidents) so I do not know if the above works the same.

Please test locally to see if the `exampleSite` works with the basic version of Hugo and without npm once the resources are generated.

If you do not have such a local setup then post a link here for me to clone the theme along with its committed resources and I will test it to see if it generates without a npm installation on Hugo basic.

---

<div class="post-metadata">

**Author:** ![capnfabs](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/capnfabs/32/9593_2.png) [@capnfabs](https://discourse.gohugo.io/u/capnfabs)\
**Post date:** [December 29, 2020, 12:18pm UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/5 "2020-12-29T12:18:58Z")

</div>

Thanks @alexandros!

> I would think that you need to generate the theme’s resources and then commit them in the theme repo

I was doing this before, and switched to js.Build ([commit](https://github.com/capnfabs/paperesque/commit/91a8496b97145a4ef1d4deeb75125bdc3740700f)) once it landed in Hugo, and after getting requests from users on [how to adapt parts of the theme JS to their own themes](https://github.com/capnfabs/paperesque/issues/7). I’ll switch back to that to get the theme working for the Hugo themes site again.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 31, 2020, 12:19pm UTC](https://discourse.gohugo.io/t/js-build-resolve-behaviour-changes-in-0-78-1/30265/6 "2020-12-31T12:19:02Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
