Open silverham opened 1 day ago
For those wondering how i got it to compile next / drupal in docker in lando with image mcr.microsoft.com/appsvc/node:20-lts_20240819.2.tuxprod
(it might not be the best way)
(though couldn't get it fully running, i get fallback-build-manifest.json
missing so i copy and paste the code to the project to test it)
# How to compile next-drupal and run inside exiting project
lando ssh -s nextjs -u root
apt-get install yarn
apt-get install git
cd /app/git-ignored/
git clone https://github.com/chapter-three/next-drupal.git
cd /app/git-ignored/next-drupal/
git checkout v1.6
yarn add vips -W
yarn install
mv /app/nextjs/node_modules/next-drupal /app/nextjs/node_modules/next-drupal.bak
ln -s /app/git-ignored/next-drupal/node_modules/next-drupal /app/nextjs/node_modules/next-drupal
# compile
npm run prepare
# How to compile next (must use a clone of an exiting project due to `pnpm` messing up node_modules`)
lando ssh -s nextjs -u root
apt-get install yarn
apt-get install git
npm install -g pnpm@8.15.4
pnpm install
# (should have types error in build)
pnpm build
mv /app/nextjs/node_modules/next /app/nextjs/node_modules/next.bak
rm /app/nextjs/node_modules/next -rf
pnpm next-with-deps /app/nextjs/
# Then cancel.
# (should not have types error in build now)
pnpm build
# Then copy and paste compile *.js files to your original project for debugging.
Package containing the bug
next-drupal (NPM package)
Describe the bug
Leaving here for documentation purposes / suggest adding extra logging (instead of 422 error but no logging even if debug is enabled)
If you have updated Acquia's
drupal/acquia_cms_headles
s to 1.4.0+ then thedrupal/next module
is required to be v2.So then for your
next
npm package should be v2+ as well.Document in issue queue Otherwise, if you use v1 next npm and v2 drupal/next togther you receive an error
422 Unprocessable Entity
on API preview route.Suggest to add extra logging to v1 next-drupal version like in v2 / Why - for those interested:
If you recompile
next-drupal
to change line (1104 inasync preview()
) in file :next-drupal/packages/next-drupal/src/client.ts
to this, (like v2 logging)
You will get this error:
Which is created by the below code in
preview()
innext-drupal/packages/next-drupal/dist/index.js
where slug is undefined but it nowpath
in drupal next module v2.This is because the drupal nextjs module uses
path
instead ofslug
in v2.