hydrogen: [Bug]: Recent updates give me 'TypeError: config.plugins.map is not a function', crash
Please confirm that you have:
- Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
- Reproduced the issue in the latest CLI version.
In which of these areas are you experiencing a problem?
App, Hydrogen custom storefront
Expected behavior
npm run dev
should launch app locally without error.
Actual behavior
App doesn’t launch locally, get this error in server console:
│ config.plugins.map is not a function
│ To investigate the issue, examine this stack trace:
│ at registerCleanBugsnagErrorsFromWithinPlugins (/node_modules/@shopify/cli-hydrogen/node_modules/@shopify/cli-kit/dist/public/node/error-handler.js:137)
│ at init (/node_modules/@shopify/cli-hydrogen/node_modules/@shopify/cli-kit/dist/public/node/base-command.js:29)
│ at async runCLI (/node_modules/@shopify/cli-kit/dist/public/node/cli.js:68)
│ at async runShopifyCLI (/node_modules/@shopify/cli/dist/index.js:34)
Verbose output
chrishouck@chriss-mbp jmlshopifystore % npm run dev --verbose
npm verb cli /Users/chrishouck/.nvm/versions/node/v18.17.1/bin/node /Users/chrishouck/.nvm/versions/node/v18.17.1/bin/npm
npm info using npm@10.2.4
npm info using node@v18.17.1
npm verb title npm run dev
npm verb argv "run" "dev" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/Users/chrishouck/.npm/_logs/2024-02-05T16_01_56_480Z-
npm verb logfile /Users/chrishouck/.npm/_logs/2024-02-05T16_01_56_480Z-debug-0.log
> sanity-hydrogen-app@0.0.0 dev
> shopify hydrogen dev
╭─ error ──────────────────────────────────────────────────────────────────────╮
│ │
│ config.plugins.map is not a function │
│ │
│ To investigate the issue, examine this stack trace: │
│ at registerCleanBugsnagErrorsFromWithinPlugins │
│ (~~/node_modules/@shopify/cli-hydrogen/node_m │
│ odules/@shopify/cli-kit/dist/public/node/error-handler.js:137) │
│ at init (~~/node_modules/@shopify/cli-hydroge │
│ n/node_modules/@shopify/cli-kit/dist/public/node/base-command.js:29) │
│ at async runCLI (~~/node_modules/@shopify/cli │
│ -kit/dist/public/node/cli.js:68) │
│ at async runShopifyCLI (~~/node_modules/@shop │
│ ify/cli/dist/index.js:34) │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: config.plugins.map is not a function
npm verb exit 0
npm info ok
Reproduction steps
- npm i @shopify/cli
- npm run dev
Operating System
Mac OS Sonoma 14.3
Shopify CLI version (check your project’s package.json
if you’re not sure)
“^3.55.3”
Shell
zsh
Node version (run node -v
if you’re not sure)
v18.17.1
What language and version are you using in your application?
No response
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 4
- Comments: 22 (4 by maintainers)
Thanks for raising this issue, we are addressing it in https://github.com/Shopify/hydrogen/pull/1741 which aim to be release March 1, 2024.~~Please note that this work had been deprioritize ~~
resurrected in https://github.com/Shopify/hydrogen/pull/1786
This bug seems to be caused by a dependency of
@shopify/cli-hydrogen
:@shopify/cli-kit
version 3.51.0 (the buggy code was released there:config.plugins.map(...)
I checked the currently latest released version 3.54.4 and it has got an update:
[...config.plugins].map(...)
( https://github.com/Shopify/cli/blob/main/packages/cli-kit/src/public/node/error-handler.ts#L170 )Now I think
@shopify/cli-hydrogen
will release an update soon, in which@shopify/cli-kit
on version 3.54.4 or later will be included. But right now, you can add an override to yourpackage.json
Then run
npm update @shopify/cli-hydrogen
@jonrrivera ahhhh Bun…
I was super excited about it but ended up not using it day to day, because it struggles with overrides/resolutions by design. This may be outdated by now, but the only way to achieve dependencies overrides is via the import statement themselves (which means, there is nothing you can do about node_modules).
So I think the answer is that Bun is not stable enough at this point in time to handle this use case.
Now for the second part of your question, the snippet goes in your
package.json
.You are right when you say
shopify/cli-kit
only shows in the package-lock.json. That’s what overrides/resolutions do. It instructs the package manager to prioritize a specific version for deep dependencies.@umxr If you are going to deploy to Oxygen, you might be missing proper configuration in
remix.config.js
. Check what we have here, especially theserverMainFields
property. If you need more help please open a new issue since this is unrelated to the original problem in this thread 🙏@frandiox Hey, I know this issue has been closed but i was wondering if you could help diagnose why im getting a different set of errors, i was running into the same
config.plugins.map is not a function
error. Following the suggestions in this thread allowed me to fix this, however i am now seeing the followingSome context, I created this project using an earlier version sanity-hydrogen-demo, im upgrading my project to match the version that they are using, so im not using the latest version of hydrogen
here is why my package.json looks like
@frandiox I’m still experiencing this issue even after the update. OS: Windows 11 Node version: v21.2.0
I manually updated: “@remix-run” packages from 2.2.0 to 2.8.0. It builds fine. “@shopify/hydrogen”: “2023.10.2” -> “^2024.1.2”. It builds fine. “@shopify/remix-oxygen”: “^2.0.1” -> “^2.0.3”. It builds fine. “@shopify/cli-hydrogen”: “^6.0.2” -> “^7.1.0”. It builds fine.
But when i update “@shopify/cli”: “^3.50.2”, -> “^3.56.3” both
yarn dev
&npm run dev
fail:Also, tried automatic updates with
npx shopify hydrogen upgrade
initially, but that also fails giving the error mentioned above.really appreciate the help @fcisio ! doing this and using npm for it back and running for me 😃
Hi @jonrrivera, the fix should work.
“overrides” is a
npm
/pnpm
thing. I suspect you might be usingyarn
, if that’s the case, you want to use “resolutions” instead.You can also delete node_modules before a new fresh install.
Hi, got same issue recently, but for deploy script.
Running
npm prune
seems working to me;link to forum, where i find it: https://community.shopify.com/c/hydrogen-headless-and-storefront/hydrogen-cli-error-after-upgrading-from-2023-10-4-to-2024-01-0/m-p/2417620