firebase-framework-tools icon indicating copy to clipboard operation
firebase-framework-tools copied to clipboard

Firebase deploy with NextJS peer dependencies issues

Open imbradyboy opened this issue 3 years ago • 5 comments

As stated in the title, when running Firebase deploy on a NextJS app with peer dependency issues, the command fails with the expected unable to resolve dependency tree. Is there a way to pass in the --legacy-peer-deps flag to this command?

EDIT: tried adding an npmrc file to the root of the project but it does not get added to the functions directory built from the deploy command

imbradyboy avatar Oct 19 '22 01:10 imbradyboy

if this is related to cloud functions deploy, that should be handled inside the functions package.json, need a confirmation on this.

digimbyte avatar Oct 20 '22 05:10 digimbyte

found some tips, this is often related to the dependencies not being installed, you can re-install the packages to a specific version and append the command onto it npm add xxxx --legacy-peer-deps

another, if this is related to react, is to install a specific version of React and facilitate tree shaking where needed. this could apply to other packages but from my search, it seems to be an issue with older React libraries designed for node 7 and older.

digimbyte avatar Oct 20 '22 05:10 digimbyte

found some tips, this is often related to the dependencies not being installed, you can re-install the packages to a specific version and append the command onto it npm add xxxx --legacy-peer-deps

another, if this is related to react, is to install a specific version of React and facilitate tree shaking where needed. this could apply to other packages but from my search, it seems to be an issue with older React libraries designed for node 7 and older.

Thanks for the response. The issue with these solutions is that running ‘firebase deploy’ on a NextJS app will automatically build the functions folder and deploy. So any attempt to modify package.json or the npm flags gets overwritten immediately.

Unfortunately in my scenario this is not an app that I have written and has dozens of peer dependency issues from the previous developers, so changing the version of React won’t solve the issue either.

There should be a way to specify a flag or something on the firebase deploy command to insert your own npm config

imbradyboy avatar Oct 20 '22 11:10 imbradyboy

Interesting, probably worth us copying over any npmrc into the code generated Cloud Function

jamesdaniels avatar Oct 20 '22 17:10 jamesdaniels

Interesting, probably worth us copying over any npmrc into the code generated Cloud Function

@jamesdaniels thanks. Is there a timeline for this update?

imbradyboy avatar Oct 21 '22 15:10 imbradyboy