slice-machine icon indicating copy to clipboard operation
slice-machine copied to clipboard

Cannot find module '@prismicio/types-internal/lib/customtypes'

Open HugoTrick opened this issue 9 months ago • 8 comments

Hello, I have a problem when I try to initialize my existing Nuxt project with Prismic

Versions

  • nuxt: v3.8.2
  • node: v20.11.0

Reproduction

I run the command : npx @slicemachine/init@latest

This is the error that i get :

node:internal/modules/cjs/loader:1144
  const err = new Error(message);
              ^

Error: Cannot find module '@prismicio/types-internal/lib/customtypes'
Require stack:
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/index.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/index.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/lib/mockSlice.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/slices/SlicesManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/SliceMachineManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/createSliceMachineManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/index.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/cli.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js:4:23)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/index.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/index.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/lib/mockSlice.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/slices/SlicesManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/SliceMachineManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/createSliceMachineManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/index.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/cli.cjs'
  ]
}

Node.js v20.11.0

I already tried to install @prismicio/types-internal locally or globally but it won't work.

Thank you for your help.

HugoTrick avatar Apr 29 '24 11:04 HugoTrick

Hey there, we're sorry you're experiencing this error, just to be sure, are you also experiencing it when starting from a starter here? https://prismic.io/dashboard/new-repository?framework=nuxt

Could you share your package.json content also perhaps?

lihbr avatar Apr 29 '24 11:04 lihbr

Hello, yes I started with the link you just shared. It's not working at the step of npx @slicemachine/init@latest --repository XXX

This is my package.json :

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "@nuxt/devtools": "latest",
    "@types/lodash.debounce": "^4.0.9",
    "autoprefixer": "^10.4.16",
    "nuxt": "^3.8.2",
    "nuxt-simple-sitemap": "^4.1.9",
    "postcss": "^8.4.32",
    "vue": "^3.3.10",
    "vue-router": "^4.2.5"
  },
  "dependencies": {
    "@heroicons/vue": "^2.0.18",
    "@nuxt/ui": "^2.11.1",
    "axios": "^1.6.2",
    "lodash.debounce": "^4.0.8",
    "marked": "^12.0.1",
    "vue-slider-component": "^4.1.0-beta.7",
    "vue3-carousel-nuxt": "^1.1.0",
    "vue3-toastify": "^0.1.14"
  }
}

HugoTrick avatar Apr 29 '24 11:04 HugoTrick

Hey there, I tried reproducing your issue using Node 20.11.0 and Nuxt 3.8.2 explicitly with no luck.

Can you confirm you're experiencing the same issue starting with a new project from scratch by running the following commands?

npx nuxi@latest init
cd nuxt-app
npx @slicemachine/init@latest

Sorry for the redundancy, but I'm trying to figure out if the issue is coming from your setup or is specific to the project you're working on.

Let us know if you have any trouble going through the above ☺️

lihbr avatar Apr 29 '24 13:04 lihbr

Hey,

I have the same issue with a new project from scratch with the commands you gave me.

➜  Downloads npx nuxi@latest init
Need to install the following packages:
[email protected]
Ok to proceed? (y) y

✔ Which package manager would you like to use?
npm
◐ Installing dependencies...                                        5:41:50 PM

> postinstall
> nuxt prepare

✔ Types generated in .nuxt                                         5:42:30 PM

added 824 packages, and audited 826 packages in 40s

166 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
✔ Installation completed.                                          5:42:30 PM

✔ Initialize git repository?
No
                                                                    5:42:33 PM
✨ Nuxt project has been created with the v3 template. Next steps:
 › cd nuxt-app                                                      5:42:33 PM
 › Start development server with npm run dev                        5:42:33 PM
➜  Downloads cd nuxt-app

➜  nuxt-app npx @slicemachine/init@latest

node:internal/modules/cjs/loader:1144
  const err = new Error(message);
              ^

Error: Cannot find module '@prismicio/types-internal/lib/customtypes'
Require stack:
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/index.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/index.js
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/lib/mockSlice.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/slices/SlicesManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/SliceMachineManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/createSliceMachineManager.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/index.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs
- /Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/cli.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js:4:23)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/Document.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/generators/index.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/mocks/lib/index.js',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/lib/mockSlice.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/slices/SlicesManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/SliceMachineManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/createSliceMachineManager.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/index.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs',
    '/Users/hugo/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/cli.cjs'
  ]
}

Node.js v20.11.0

HugoTrick avatar Apr 29 '24 15:04 HugoTrick

Hey there, thanks for trying the above!

This is odd. I asked colleagues of mine to confirm and attempt it on their end with no luck either.

Can you share more information about your setup? OS, npm version, .npmrc file content if you have any (maybe at your home folder?), anything you think might be helpful to attempt troubleshoot your issue~

Thanks!

lihbr avatar Apr 30 '24 12:04 lihbr

facing same issue with next js too it was working before this week

getting this error:

NODE version: 21.1.0 pnpm: 8.10.2

Error: Invalid context provided at CustomTypesClient.fetch (/home/bruno/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/custom-types-client/dist/client.cjs:346:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async CustomTypesClient.getAllCustomTypes (/home/bruno/.npm/_npx/b6923b01b288b666/node_modules/@prismicio/custom-types-client/dist/client.cjs:83:12) at async CustomTypesManager.fetchRemoteCustomTypes (/home/bruno/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/managers/customTypes/CustomTypesManager.cjs:194:12) at async Task.task (/home/bruno/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs:865:35)

Nirvana55 avatar May 06 '24 09:05 Nirvana55

Hey @Nirvana55, thanks for tuning in!

I'm not sure that's the same issue, can you give it a try with an active LTS version of Node.js? (e.g. version 22 or 20)

lihbr avatar May 07 '24 09:05 lihbr

Hey @lihbr

The issue I faced was when working with multiple Prismic repos on the same project. Initially, I setup a new Prismic repo successfully. However, after stashing changes and switching to different branch, I attempted to initialize another Prismic repo which led to the above issue. Maybe its due cache on the custom types. I attempted to clear the npx cache but the problem persisted.

Eventually, I just deleted my all branch and re-cloned my project, and tried initializing the same Prismic repo, which worked fine now.

Nirvana55 avatar May 08 '24 07:05 Nirvana55

Hey @lihbr I still have the issue. I tried 4 node versions (including LTS versions) and same error on all the versions.

HugoTrick avatar May 14 '24 09:05 HugoTrick

Hey @HugoTrick, thanks for following up, we'd like more information from your end to attempt to troubleshoot that further as we weren't able to reproduce your results:

Can you share more information about your setup? OS, npm version, .npmrc file content if you have any (maybe at your home folder?), anything you think might be helpful to attempt troubleshoot your issue~?

Thanks!

lihbr avatar May 14 '24 10:05 lihbr

Hey, I'm on a Macbook Pro M1 (OS Sonoma 14.5). My NPM version is 10.5.2, and I don't have an .npmrc file. I finally used an other computer to be able to run the command and I can now use Prismic, but it could be great if you find a solution to this.

Thanks.

HugoTrick avatar May 14 '24 16:05 HugoTrick

Hey @HugoTrick, thanks for sharing more details!

I just tried on a similar setup (MBP M3 Mac OS Sonoma 14.3, NPM 10.5.2., Node 20.11.0) but really no luck. I hate it when I come back with news like this à-la "works on my machine" kinda but it has proven quite hard trying to reproduce your issue for me and other colleagues I asked internally. My last hunch being that maybe you're working off an enterprise network that proxies the NPM registry (and perhaps bans @prismicio/types-internal as a result) but this feels quite far-fetched and I won't put money on the table that this is your setup~

I'm glad you got it working on another computer but I want to acknowledge that this is definitely now the kind of experience we want to offer. We'll keep an open ear for this issue should it come back again but for now we'll close this issue until someone is able to provide more details/ideas about it.

lihbr avatar May 15 '24 09:05 lihbr