Issue: Running “npm run dev” for the Shopify app PHP template failed with “Cannot initialize Shopify API Library. Missing values for: scope,” despite SCOPES being set in .env (read_products,write_products).
Tried: A suggestion to run “npm run deploy” did not resolve it initially.
Resolution/Update: After executing “npm run build --api-key=REPLACE_ME” followed by “npm run deploy,” the scopes appeared on the app’s API access page, and “npm run dev” started successfully.
Notes:
No changes were made to .env or .toml before it began working.
Scopes (API permissions) may not be recognized until the app is built and deployed, even if defined in .env.
Outcome: Resolved. Practical takeaway: perform a build and deploy to propagate scopes before running the local dev server. Root cause remains unclear.
Update: Issue is kind of resolved.
I’ve tried to build the app before, but with constant errors.
Now, after “npm run build --api-key=REPLACE_ME” and then deploy “npm run deploy” scopes appeared on the app’s API access page and “npm run dev” started successfully. Not sure where the problem was, I haven’t changed neither .env nor .toml configs.