prismicio / prismic-cli

Prismic command line tool
40 stars 14 forks source link

Error: Cannot find module 'next-transpile-modules' #77

Closed darrenbarklie closed 3 years ago

darrenbarklie commented 3 years ago

Following the documentation, but encountering the same error on multiple attempts.

Encounter this hang during installation:

~/Code/prismic-slicemachine-2  prismic sm --setup
✔ Downloading files from server
⠋ Installing dependencies
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: prismic-slicemachine-2@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1" from next-slicezone@0.0.12
npm ERR! node_modules/next-slicezone
npm ERR!   next-slicezone@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/daz/.npm/eresolve-report.txt for a full report.

Eventually passes, however attempting to run the project produces:

~/Code/prismic-slicemachine-2  npm run dev                               

> prismic-slicemachine-2@0.1.0 dev
> next dev

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Error: Cannot find module 'next-transpile-modules'
Require stack:
- /Users/daz/Code/prismic-slicemachine-2/next.config.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/config.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/next-server.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/next.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/lib/start-server.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/cli/next-dev.js
- /Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/daz/Code/prismic-slicemachine-2/next.config.js:1:16)
    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:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at loadConfig (/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/config.js:8:94)
    at new Server (/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/next-server.js:1:4533)
    at new DevServer (/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/next-dev-server.js:1:2964)
    at createServer (/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/next.js:2:607)
    at start (/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/lib/start-server.js:1:323) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/daz/Code/prismic-slicemachine-2/next.config.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/config.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/next-server/server/next-server.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/next.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/server/lib/start-server.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/cli/next-dev.js',
    '/Users/daz/Code/prismic-slicemachine-2/node_modules/next/dist/bin/next'
  ]
}
npm ERR! code 1
npm ERR! path /Users/daz/Code/prismic-slicemachine-2
npm ERR! command failed
npm ERR! command sh -c next dev

Manually installing with npm install next-transpile-modules doesn't resolve the issue.

Appreciate any support in unblocking.

lihbr commented 3 years ago

Hey @darrenbarklie, thanks for submitting an issue!

I tried to reproduce using the following ways using both npm@6.14.9 and yarn@1.22.4 on node@14.15.3 and prismic-cli@3.8.6 (well, more or less the latest versions) without success using the following process:

  1. $ npx create-next-app
  2. $ prismic sm --setup
  3. $ npm run dev # or yarn dev

Can you share your node version, npm version, prismic-cli version, and your package.json? A consistent way of reproducing would also help!

Thanks, looking forward to sorting that out 🙂

(cc @hypervillain, just in case you have an idea already)

darrenbarklie commented 3 years ago

Hey Lucie, I appreciate the fast response.

I'm running prismic-3.8.3-beta.0, fetched with npm 7.4.3 on node v15.7.0 on Mac M1.

npx create-next-app prismic-test
prismic sm --setup --framework next

Blocking error:

✔ Downloading files from server
⠋ Installing dependencies
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   peer react@">=16.0.0" from prismic-reactjs@1.3.3
npm ERR!   node_modules/prismic-reactjs
npm ERR!     prismic-reactjs@"*" from the root project
npm ERR!     peer prismic-reactjs@"^1.3.1" from essential-slices@1.0.3
npm ERR!     node_modules/essential-slices
npm ERR!       essential-slices@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1" from essential-slices@1.0.3
npm ERR! node_modules/essential-slices
npm ERR!   essential-slices@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

...

 ERROR  ENOENT: no such file or directory, open 'pages/_app.js'       09:00:43

  at Object.openSync (node:fs:490:3)
  at Object.writeFileSync (node:fs:1542:35)
  at Object.write (/usr/local/lib/node_modules/prismic-cli/bin/common/utils/files.js:26:20)
  at /usr/local/lib/node_modules/prismic-cli/bin/commands/slicemachine/commands/setup.js:105:18
  at Array.forEach (<anonymous>)
  at createFiles (/usr/local/lib/node_modules/prismic-cli/bin/commands/slicemachine/commands/setup.js:100:9)
  at _callee3$ (/usr/local/lib/node_modules/prismic-cli/bin/commands/slicemachine/commands/setup.js:283:13)
  at tryCatch (/usr/local/lib/node_modules/prismic-cli/node_modules/regenerator-runtime/runtime.js:63:40)
  at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/prismic-cli/node_modules/regenerator-runtime/runtime.js:293:22)
  at Generator.next (/usr/local/lib/node_modules/prismic-cli/node_modules/regenerator-runtime/runtime.js:118:21)

Hope this helps, but let me know if you require further @lihbr, @hypervillain.

lihbr commented 3 years ago

Thanks for sharing that! When syncing to your version I was able to reproduce it.

Looks like npm 7 now considers peer dependencies as required, leading to dependencies not installing themselves at all when there's a mismatch.

I'll check this afternoon to extend the range of React peer dependency on next-slicezone, in the meantime I can recommend you to stick with the latest LTS version of node (14.15.4) which comes with npm 6 if possible.

darrenbarklie commented 3 years ago

Thanks for the link. I wasn't aware of this change for NPM7, but now note the optional --legacy-peer-deps flag. I'll also revisit this later and report back if I can find a fix for v7 before rolling back to v6.

darrenbarklie commented 3 years ago

Hi again @lihbr - I can confirm I'm up and running by reverting to node v14.15.4. Appreciate the guidance.

lihbr commented 3 years ago

Fixed 🙌 https://github.com/prismicio/slice-machine/commit/b131f90be582b6fc97f5c7b145b1a6afa156a41b

Thanks again @darrenbarklie