# js.BUILD

**URL:** <https://discourse.gohugo.io/t/js-build/49057>\
**Category:** support\
**Created:** [March 26, 2024, 12:32pm UTC](https://discourse.gohugo.io/t/js-build/49057 "2024-03-26T12:32:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devendhiran.d\_Devar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/devendhiran.d_devar/32/21586_2.png) [@Devendhiran.d\_Devar](https://discourse.gohugo.io/u/Devendhiran.d_Devar)\
**Post date:** [March 26, 2024, 12:32pm UTC](https://discourse.gohugo.io/t/js-build/49057/1 "2024-03-26T12:32:26Z")

</div>

I am attempting to use `js.build` in my code, but I’m encountering a _ **“Parsing error: ‘import’ and ‘export’ may appear only with ‘sourceType: module’”** _ in my JavaScript file.

My code:

**.HTML**

```auto
  {{ $js := resources.Get "/js/index.js" | js.Build (dict "params" (dict "list" .Site.Params.variable)) }}

```

. **js**

import \* as params from ‘@params’;

console.log(params.list);

**.config.yaml**

```auto
params:
  variable: ["x,y"]

```

**Hugo Vertion: 0.121.1**

Have any idea where I made a mistake?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 26, 2024, 12:48pm UTC](https://discourse.gohugo.io/t/js-build/49057/2 "2024-03-26T12:48:16Z")

</div>

Rename your Javascript to .mjs instead of .js, or change the `type` in your package.json to `module`. The issue is not with Hugo but how node/npm (and thus esbuild) handle files. If you want to force a module javascript file rename it to .mjs, if you want to force a commonJS file use .cjs. If you use .js as file extension then esbuild is checking the package.json for the type attribute, if it is not set it assumes commonjs.
