prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

Support for pnpm/pnpx #768

Closed poteirard closed 1 year ago

poteirard commented 1 year ago

Is your feature request related to a problem? Please describe.

It seems it doesn't work if you use pnpm instead of npm. It will be nice to support it by using pnpx if possible.

Describe the solution you'd like

In the same way, it detects the framework, it could be nice to detect the package manager.

Describe alternatives you've considered

I tried to run pnpx @slicemachine/init --repository gerardbrullphoto instead of npx

I'm trying to check the code to reproduce the steps in my machine with pnpx but it's hard to follow for me.

Additional context

I tried to follow the initial tutorial but it doesn't seem to work with pnpx.

The error seems to be related because I'm using pnpm.


The integrity of 2066 files was checked. This might have caused installation to take longer.
.../Library/pnpm/store/v3/tmp/dlx-46292  | Progress: resolved 141, reused 109, downloaded 32, added 142, done
You're about to configure Slicemachine... Press ctrl + C to cancel
βœ” Logged in as ...@gmail.com
βœ” Next.js detected
βœ” Project configured! Ready to start
β ¦ Installing Slice MachineError! Command failed: npm install --save-dev slice-machine-ui @prismicio/types
npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/.../.npm/_logs/2022-12-17T17_58_25_167Z-debug-0.log```
poteirard commented 1 year ago

Workaround:

  1. Install the slicemachine init package in your pnpm project: pnpm add @slicemachine/init
  2. Go to node_modules/@slicemachine/init/build/index.js and replace all occurrences of npm for pnpm.
  3. Add a script in your project package.json "initt": "node_modules/@slicemachine/init/build/index.js --repository <NAME_OF_YOUR_REPO>" and run it.
lihbr commented 1 year ago

Hey there, thanks for opening an issue and sharing comprehensive information and workaround!

Supporting more package managers is definitely something we want to do. In that regard:

Thanks for your understanding :)

joerambo commented 1 year ago

@poteirard Thanks for posting this workaround. Exactly what I needed to get hooked up to new project.

nd0nd0 commented 1 year ago

Hey there, thanks for opening an issue and sharing comprehensive information and workaround!

Supporting more package managers is definitely something we want to do. In that regard:

  • We have a rework of the init command on the way bringing support for more package managers (adding support for berry, pnpm & pnpm@6, and even bun)
  • I can't confirm we'll be able to act on it earlier, but I'll bring it to the team to perhaps make the current init command a bit more flexible.

Thanks for your understanding :)

Any updates on this?

Currently running pnpm slicemachine gives off an error 'start-slicemachine' is not recognized as an internal or external command, operable program or batch file.

lihbr commented 1 year ago

Hey there, it should support it, can you share more about your setup?

I tried the following with success on my end (Node 16.20.0, pnpm 8.2.0, Slice Machine 1.0.2)

# init process
pnpx @slicemachine/init@latest

# start process
pnpm slicemachine
nd0nd0 commented 1 year ago

Hey there, it should support it, can you share more about your setup?

I tried the following with success on my end (Node 16.20.0, pnpm 8.2.0, Slice Machine 1.0.2)

# init process
pnpx @slicemachine/init@latest

# start process
pnpm slicemachine

I am currently running on Windows using node 18.15.0, pnpm 8.3.1, slice machine 1.0.2 and nextjs 13 (pages dir).

remoblaser commented 1 year ago

Same issue here, initiated with pnpm dlx @slicemachine/init@latest

mdeclercq commented 1 year ago

Hi, I tried reproducing the issue with the same settings as @nd0nd0: Windows, Node 18.15.0, pnpm 8.3.1, slice machine 1.0.2 and nextjs 13 but I did not encounter the error. @remoblaser, could you please share details about your setup (OS, versions of node/pnpm)? This could help help isolate the issue.

By any chance, do you have a public minimum reproduction repository that we could refer to? Thanks,

mdeclercq commented 1 year ago

This could be because pnpm does not install bin executables of transitive dependencies. See https://github.com/pnpm/pnpm/issues/899. The same happens with Yarn 2+ (Berry). The start-slicemachine script is part of the start-slicemachine package, a dependency of slice-machine-ui.

We opened a ticket internally to fix the issue. As a workaround, you could install start-slicemachine as a dev dependency and remove it once this issue is fixed.

mdeclercq commented 1 year ago

Hi @nd0nd0, @remoblaser, @poteirard,

This should be fixed for pnpm and yarn in the latest release 1.4.0.

remoblaser commented 1 year ago

@mdeclercq awesome! Looking forward to it. Thanks for your efforts!

nd0nd0 commented 1 year ago

@mdeclercq, thank you for your involvement in this. I have tested the 1.4.0 release and it worked out well.

poteirard commented 1 year ago

Excellent, closing the issue then :) Many thanks!