Trying to set up next.js test - slicemachine error ERR_REQUIRE_ESM

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:

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

      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) {

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


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

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?


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 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.