production icon indicating copy to clipboard operation
production copied to clipboard

Admin build fails with NPM 8.4.0 (older Shopware 6 version) and now with NPM 8.6.0

Open AndreasA opened this issue 2 years ago • 15 comments

PHP Version

8.4

Shopware Version

6.4.7.0

Expected behaviour

Admin build to succeed.

Actual behaviour

npm clean-install fails. Not sure if the lock file should be updated or the admin task should instead just use npm install instead of npm clean-install because npm install works. Probably best to use npm install instead and also do so in build-storefront.sh

How to reproduce

Install node ^16, npm ^8.4 and install Shopware 6.4.7.0 in the production template and execute ./bin/build-administration.sh . It will fail with:

npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR! 
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
....

AndreasA avatar Feb 04 '22 07:02 AndreasA

Hmm we should do npm install --no-save or pin the older npm version

shyim avatar Feb 04 '22 07:02 shyim

You could install https://github.com/FriendsOfShopware/shopware-cli and use shopware-cli project admin-build until its fixed somehow in the template

shyim avatar Feb 04 '22 07:02 shyim

I have created an internal issue and pushed it https://issues.shopware.com/issues/NEXT-19945?

shyim avatar Feb 04 '22 07:02 shyim

For now I have pinned the version to 8.3 in the CI. though I think using npm install --no-save might make more sense.

AndreasA avatar Feb 04 '22 07:02 AndreasA

We had the same issue. npm released version 8.4.1 8 hours ago (https://www.npmjs.com/package/npm?activeTab=versions). We solved this by using npm version 8.4.0 instead of latest.

The "issue" was created because npm fixed a bug. They didn't validate the lockfiles: https://github.com/npm/cli/commit/457e0ae61bbc55846f5af44afa4066921923490f

Drumm3r avatar Feb 04 '22 11:02 Drumm3r

Hmm... Interesting, personally I think that this is a breaking change in NPM and should have been a NPM v9.x release but that aside it seems to be easily fixable by calling npm install once to update the lock file accordingly.

AndreasA avatar Feb 07 '22 06:02 AndreasA

So what is the fix for this issue? It's still present in v6.4.8.0...

ioanok avatar Feb 10 '22 07:02 ioanok

@shyim I could be wrong but I think the shopware/platform pipelines are not also failing due to this: cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.

I get e.g. now for the PHPUnit pipelines: https://github.com/shopware/platform/runs/5463997380?check_suite_focus=true

AndreasA avatar Mar 08 '22 12:03 AndreasA

Is your fork maybe out of date?

shyim avatar Mar 08 '22 12:03 shyim

@shyim shouldn't be I just fetched origin/trunk today. but the same issue is on the trunk branch on a commit from a few hours ago, see: https://github.com/shopware/platform/runs/5464261376?check_suite_focus=true https://github.com/shopware/platform/commit/575ea227c89ac11bef4a3855abd8044f1e52abeb https://github.com/shopware/platform/commits/trunk

I think it happens since sometime yesterday after checking the commit history.

AndreasA avatar Mar 08 '22 13:03 AndreasA

I've stubmled upon this with some team members today. ~After performing npm-install inside the administration everything was fine.~

~Interesstingly it seems that I had those missing packages inside the npm-cache while other's didn't. For me everything was fine but on a fresh install this failed.~

~Here's the quickfix:~

Edit#1

Downgrading npm to 8.3.2 was fixing it.

$ npm install -g 8.3.2

christoph-kluge avatar Apr 13 '22 12:04 christoph-kluge

8.4 and 8.5 seems to work now with 6.4.10.0. However, there seems to be a new issue with 8.6.0:

npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^4.19.1 || ^5.3.0" from [email protected]
npm ERR!   node_modules/eslint-config-airbnb-base
npm ERR!     dev eslint-config-airbnb-base@"13.2.0" from the root project
npm ERR!     eslint-config-airbnb-base@"^13.2.0" from @shopware-ag/[email protected]
npm ERR!     node_modules/@shopware-ag/eslint-config-base
npm ERR!       @shopware-ag/eslint-config-base@"1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

AndreasA avatar Apr 13 '22 14:04 AndreasA

Regarding 8.6.0 it is most likely related to this: https://github.com/npm/cli/issues/4664 as mentioned in the ticket it was probably closed pre-maturely and is actually an issue with 8.6.0 but not 100% sure, will depend on feedback on that issue.

AndreasA avatar Apr 15 '22 09:04 AndreasA

In any case it would probably make sense to add some CI tests that automatically tries to build storefront/admin with new released NPM / node version to ensure it still works or not and if not, it should be fixed. Or even better to ensure potential issues cannot occur in the first place lilke e.g. an out-of-date lock file (8.4.0 issue) and now I would guess a dependency was updated but not its own dependencies which results in the issue above?

Though I doubt all these issues can be avoided. Personally I think NPM is more at fault here for changing such behaviors in minor versions.

AndreasA avatar Apr 15 '22 10:04 AndreasA

Any news regarding NPM 8.6 and newer?

AndreasA avatar May 10 '22 06:05 AndreasA

I have the same error on build with image shopware/development:7.4-composer-2 where is new npm version (8.15.0)

According to https://github.com/npm/cli/issues/5113

you can change in build-administration.sh from: npm clean-install --prefix "$path" to: npm clean-install --legacy-peer-deps --prefix "$path"

or skip checking if exists package-lock.json and use 'npm install --prefix'. First solution with legacy-peer-deps flag works for me.

lutek avatar Oct 10 '22 12:10 lutek

In newer Shopware versions, it is fixed as we have updated that files

shyim avatar Oct 25 '22 06:10 shyim

We still have this issue, the quickfix

npm clean-install --legacy-peer-deps --prefix "$path"

works but is a little annoying due to the merges from the upstream, but fine. We are still locked on 16.10.0 in our prod builds, are there any benefits in the newer version other then less depcreation warnings?

Node: v18.12.1 NPM: 8.19.2 Shopware: 6.4.17.2

=> Installing npm dependencies for swag-language-pack
npm ERR! code EUSAGE
npm ERR! 
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR! 
 -------------------- ------------------------------------------------------------- 
  Symfony                                                                           
 -------------------- ------------------------------------------------------------- 
  Version              5.4.15                                                       
  Long-Term Support    Yes                                                          
  End of maintenance   11/2024 (in +743 days)                                       
  End of life          11/2025 (in +1108 days)                                      
 -------------------- ------------------------------------------------------------- 
  Kernel                                                                            
 -------------------- ------------------------------------------------------------- 
  Type                 Shopware\Core\Kernel                                         
  Environment          dev                                                          
  Debug                true                                                         
  Charset              UTF-8                                                        
  Cache directory      ./var/cache/dev_hdd94adac0ddc0a47e9674f99dcc037a2 (7.7 MiB)  
  Build directory      ./var/cache/dev_hdd94adac0ddc0a47e9674f99dcc037a2 (7.7 MiB)  
  Log directory        ./var/log (106.3 MiB)                                        
 -------------------- ------------------------------------------------------------- 
  PHP                                                                               
 -------------------- ------------------------------------------------------------- 
  Version              8.0.25                                                       
  Architecture         64 bits                                                      
  Intl locale          de_DE                                                        
  Timezone             UTC (2022-11-18T07:13:40+00:00)                              
  OPcache              true                                                         
  APCu                 true                                                         
  Xdebug               true                                                         
 -------------------- ------------------------------------------------------------- 

Isengo1989 avatar Nov 18 '22 07:11 Isengo1989