nuxt-community / axios-module

Secure and easy axios integration for Nuxt 2
https://axios.nuxtjs.org
MIT License
1.2k stars 245 forks source link

npm prune --production deletes axios dependency #568

Open dschreij opened 2 years ago

dschreij commented 2 years ago

We have an app using @nuxtjs/axios 5.13.6 and nuxt 2.15.8. This works fine in dev mode, and when building for production. If we call npm prune --production after the build operation has completed, the production build no longer works and prints the error:

 ERROR  Cannot find module 'axios' from '/frontend/packages/website'                    16:34:25

  at Function.resolveSync [as sync] (/frontend/node_modules/resolve/lib/sync.js:111:15)
  at /home/daniel/git/cargoplot/frontend/node_modules/vue-server-renderer/build.prod.js:1:77905
  at Object.<anonymous> (webpack:/external "axios":1:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Module.<anonymous> (server.js:23239:23)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at updateModules (.nuxt/store.js:18:0)
  at Module.<anonymous> (.nuxt/store.js:23:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Object.<anonymous> (server.js:15281:18)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at server.js:118:18
  at Object.<anonymous> (server.js:121:10)
  at o (/frontend/node_modules/vue-server-renderer/build.prod.js:1:77799)
  at /frontend/node_modules/vue-server-renderer/build.prod.js:1:78392
  at new Promise (<anonymous>)

so it appears as if the axios dependency is removed by the prune operation. If we add axios as a direct dependency to package.json it doesn't happen anymore, but we would like @nuxtjs/axios to specify and determine the axios version that is to be used. I don't remember when this issue started popping up, but is it due to a recent change of @nuxtjs/axios? Is axios now listed as a peer dependency instead of a direct dependency perhaps?