1

I have a Vue Storefront 2 project with Magento 2 as it CMS. Locally everything runs fine. When I try to run NPM install on my Plesk server before I can build and deploy it, it gives the following error:

npm ERR! code 1
npm ERR! path /var/www/vhosts/vuestorefront2.dev/node_modules/deasync
npm ERR! command failed
npm ERR! command sh -c node ./build.js
npm ERR! linux-x64-node-16 exists; testing
npm ERR! Problem with the binary; manual build incoming
npm ERR! stdout=
npm ERR! err=Error: Command failed: /opt/plesk/node/16/bin/node quick-test.js
npm ERR! /var/www/vhosts/vuestorefront2.dev/node_modules/bindings/bindings.js:135

I have tried to remove all references of deasync in my package-lock.json. Even though NPM install then runs and allows me to build to project afterwards, it did not load any products from Magento anymore on the deployed instance. Locally I do however fetch and display products succesfully.

kissu
  • 40,416
  • 14
  • 65
  • 133
Craws
  • 576
  • 4
  • 30
  • 1
    Tried building it locally? Your Plesk server properly supports the v16 of Node? – kissu May 23 '22 at 13:00
  • Yes, Plesk is running at 16.15.0, locally I am at 16.14.0. Did not try to build it locally, can you tell me how I would deploy the locally build project on my Plesk server? – Craws May 23 '22 at 13:02
  • 1
    No, build it locally to be sure that it's working fine. I'm assuming that you just tried to run the dev server but maybe you've already built it? – kissu May 23 '22 at 13:34
  • Yes! I've just build my project locally using npm build (wich executed nuxt build). I'll test it out locally before I try to deploy it online :) – Craws May 23 '22 at 13:36
  • 1
    Run `npm run start` locally to see if it's a Nuxt issue or a Plesk one. – kissu May 23 '22 at 13:38
  • Same problem... So it's a project error, the weird part is it does have the correct magento.url/GraphQl, it also loads the correct stock image. It does not correctly fetch categories or products, however:? – Craws May 23 '22 at 13:44
  • 1
    Maybe share the code of those parts. Also, I highly recommend not messing around with your `package-lock.json`, let it as is. If you already touched it, remove all of your `node_modules`, the lock file and install all of them again. It is not directly related to your issue but it could still avoid some future problems. – kissu May 23 '22 at 13:47

1 Answers1

2

When you have an issue regarding a build remotely, the first step is usually to build it locally (with something like npm run build, then run it locally npm run start) to be sure if it's a Nuxt issue or a hosting/platform issue.

Here, it looked like OP could fix his problem by forcing a specific endpoint to use the production URL. Maybe he is lacking some local server.

This fixed the issue

publicRuntimeConfig: {
  middlewareUrl: process.env.NODE_ENV === "production"
    ? "https://example.com/api/" // Your production URL
    : "http://localhost:3000/api/",
}
kissu
  • 40,416
  • 14
  • 65
  • 133