# Trying to set up next.js test - slicemachine error ERR\_REQUIRE\_ESM

**URL:** <https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302>\
**Category:** Developing with Prismic\
**Tags:** nextjs\
**Created:** [December 9, 2021, 8:08pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302 "2021-12-09T20:08:33Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathancdev](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@jonathancdev](https://community.prismic.io/u/jonathancdev)\
**Post date:** [December 9, 2021, 8:08pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/1 "2021-12-09T20:08:33Z")

</div>

Hello,  
I'm trying to get started with Prismic and I'm already running into a problem. I am following the guide to setup a project with nextjs. Everything works smoothly until I attempt to run slicemachine. It appears there is a problem in the node\_modules communication between "ora" and "@slicemachine". I have tried the suggested solution of changing the filename in question to index.cjs and removing the "type: module" in the package.json. Here is the CLI readout:

```auto
You're about to configure Slicemachine... Press ctrl + C to cancel
✔ Logged in as ********
✔ Next.js detected
? Connect a Prismic Repository or create a new one Create a new Repository
ℹ The name acts as a domain/endpoint for your content repo and should be completely unique.
? Name your Prismic repository https:// ********
✔ We created your new repository https:// ********
✔ The Prismic Visual Builder was installed successfully
✔ Project configured! Ready to start
■ Run npm run slicemachine to now launch your Local Builder
********@********  ******** % npm run slicemachine

> slicemachine
> start-slicemachine

node:internal/modules/cjs/loader:1125
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/ ********/******** /nextjs/ ******** /node_modules/ora/index.js
require() of ES modules is not supported.
require() of /Users/ ********/******** /nextjs/ ********/node_modules/ora/index.js from /Users/******** / ********/nextjs/******** /node_modules/@slicemachine/core/build/src/utils/cliLogs.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/ ********/******** /nextjs/ ******** /node_modules/ora/package.json.

    at new NodeError (node:internal/errors:363:5)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1125:13)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/Users/ ********/******** /nextjs/ ******** /node_modules/@slicemachine/core/build/src/utils/cliLogs.js:8:31)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32) {
  code: 'ERR_REQUIRE_ESM'
}

```

Please help as I would really love to use Prismic on a project.

Thanks!

---

<div class="post-metadata">

**Author:** ![jonathancdev](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@jonathancdev](https://community.prismic.io/u/jonathancdev)\
**Post date:** [December 9, 2021, 10:45pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/2 "2021-12-09T22:45:28Z")

</div>

Ok I was trying to investigate further and upon running "npm update" I found a discrepancy in the dependencies:

```auto
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: ora@6.0.1
npm WARN node_modules/ora
npm WARN ora@"^6.0.1" from the root project
npm WARN 1 more (slice-machine-ui)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer ora@"^5.4.1" from @slicemachine/core@1.0.1
npm WARN node_modules/@slicemachine/core
npm WARN @slicemachine/core@"^1.0.1" from slice-machine-ui@0.1.2
npm WARN node_modules/slice-machine-ui

```

I ran npm install ora@5.4.1 and now I am able to launch the slicemachine server.

Can anyone confirm this is ok?

Thanks

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [December 15, 2021, 5:04pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/4 "2021-12-15T17:04:50Z")

</div>

Hello @jonathancdev

Welcome to the Prismic community, and thanks for reaching out to us.

To set up the Slice machine, you need at least [Node.js 12.0](https://nodejs.org/) or later. Check this by running node -v in your terminal.

Can you also paste your `package.json` here? We don't need to install `npm install ora@5.4.1`. You might need to update npm version too. Try running `npm install -g npm@latest`.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![hi15](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@hi15](https://community.prismic.io/u/hi15)\
**Post date:** [March 18, 2022, 1:26pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/6 "2022-03-18T13:26:57Z")

</div>

I have this error but I'm running Node 16.11.0 and NPM 8.5.5

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [March 18, 2022, 2:32pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/7 "2022-03-18T14:32:58Z")

</div>

Hey @hi15, which version of Slice Machine are you using?  
It shouldn’t have any issues with node 16

---

<div class="post-metadata">

**Author:** ![hi15](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@hi15](https://community.prismic.io/u/hi15)\
**Post date:** [March 18, 2022, 2:56pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/9 "2022-03-18T14:56:26Z")

</div>

Hi Pau,

I don't know - I'm just following the guide when you sign up.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/6/6d0a0d52387d017cb065681a98c2ec6b7a2fb57a.png)

See - [NextJS start project guide doesn't work](https://community.prismic.io/t/nextjs-start-project-guide-doesnt-work/9406)

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [March 18, 2022, 3:14pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/10 "2022-03-18T15:14:36Z")

</div>

Which version of the prismic cli do you have in your machine?

---

<div class="post-metadata">

**Author:** ![marc.mcintosh](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/marc.mcintosh/32/25_2.png) [@marc.mcintosh](https://community.prismic.io/u/marc.mcintosh)\
**Post date:** [March 18, 2022, 4:50pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/12 "2022-03-18T16:50:56Z")

</div>

Hi @jonathancdev

If i understand correctly, you want to update from `v0.1.2` to the most recent version?

---

<div class="post-metadata">

**Author:** ![hi15](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@hi15](https://community.prismic.io/u/hi15)\
**Post date:** [March 19, 2022, 8:55am UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/13 "2022-03-19T08:55:51Z")

</div>

I'm new to Prismic. I was wanting to try it to see if it was suitable for a future project.

I've created an account and clicked on "Next.js project" it then gives you a guide on the right hand side to get started. I have followed those instructions perfectly and it doesn't work. Everything will be the latest version.

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [March 22, 2022, 1:57am UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/14 "2022-03-22T01:57:46Z")

</div>

Hello @hi15, if you want you can send us your project code repository and the instructions to run it so we can try and see the error on our end.

---

<div class="post-metadata">

**Author:** ![isak](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/isak/32/4169_2.png) [@isak](https://community.prismic.io/u/isak)\
**Post date:** [March 22, 2022, 8:54am UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/15 "2022-03-22T08:54:56Z")

</div>

This error is happening for me as well, on a fresh install with only slicemachine and an empty package.json. I've opened an issue here: [Error [ERR\_REQUIRE\_ESM]: require() of ES Module · Issue #420 · prismicio/slice-machine · GitHub](https://github.com/prismicio/slice-machine/issues/420)

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [March 22, 2022, 8:59pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/16 "2022-03-22T20:59:00Z")

</div>

Hello @isak, thanks for joining the conversation and for opening the issue on Github. This helps developers better visualize use cases and track them.

---

<div class="post-metadata">

**Author:** ![dhayes](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/dhayes/32/4082_2.png) [@dhayes](https://community.prismic.io/u/dhayes)\
**Post date:** [May 31, 2022, 3:08pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/18 "2022-05-31T15:08:13Z")

</div>

Just as a follow-up to this.

The current fix seems to be to rollback node-fetch to 2.6.1:

```auto
npm i node-fetch@2.6.1

```

---

<div class="post-metadata">

**Author:** ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)\
**Post date:** [June 1, 2022, 3:47pm UTC](https://community.prismic.io/t/trying-to-set-up-next-js-test-slicemachine-error-err-require-esm/8302/21 "2022-06-01T15:47:46Z")

</div>

Thanks, @dhayes for letting us know.
