nuxt-community / axios-module

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

missing dependencies? #577

Closed robertpatrick closed 2 years ago

robertpatrick commented 2 years ago

In my very simple Nuxt.js project, I used npm install @nuxtjs/axios and then added the following to nuxt.config.js:

  modules: [
    '@nuxtjs/axios',
  ],

when I try to run npm run dev, it refuses to start due to a missing module (that wasn't missing before I switched from axios to the axios module:

 % npm run dev        

> nuxt-fundamentals@1.0.0 dev
> nuxt

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'at-least-node'
Require stack:
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/mkdirs/make-dir.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/mkdirs/index.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/copy-sync/copy-sync.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/copy-sync/index.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/index.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/utils/dist/utils.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/cli/dist/cli-index.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/cli/dist/cli.js
- /Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/nuxt/bin/nuxt.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/mkdirs/make-dir.js:9:21)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/mkdirs/make-dir.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/mkdirs/index.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/copy-sync/copy-sync.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/copy-sync/index.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/fs-extra/lib/index.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/utils/dist/utils.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/cli/dist/cli-index.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/@nuxt/cli/dist/cli.js',
    '/Users/rpatrick/Projects/research/vue/nuxt-async-data/node_modules/nuxt/bin/nuxt.js'
  ]
}
% 

After installing at-least-node and ua-parser-js to satify the missing dependencies, now I get a fatal error:

% npm run dev           

> nuxt-fundamentals@1.0.0 dev
> nuxt

 FATAL  Cannot import module '@nuxt/core'                                                                                                                                                                                   15:08:40

  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
  at Function.Module._load (node:internal/modules/cjs/loader:778:27)
  at Module.require (node:internal/modules/cjs/loader:1005:19)
  at require (node:internal/modules/cjs/helpers:102:18)
  at Object.<anonymous> (node_modules/@nuxt/server/dist/server.js:13:26)
  at Module._compile (node:internal/modules/cjs/loader:1103:14)
  at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
  at Module.load (node:internal/modules/cjs/loader:981:32)
  at Function.Module._load (node:internal/modules/cjs/loader:822:12)
  at Module.require (node:internal/modules/cjs/loader:1005:19)

   ╭──────────────────────────────────────────────╮
   │                                              │
   │   ✖ Nuxt Fatal Error                         │
   │                                              │
   │   Error: Cannot import module '@nuxt/core'   │
   │                                              │
   ╰──────────────────────────────────────────────╯

 % 

Surely I must be doing something wrong...

kissu commented 2 years ago

Try maybe with yarn. It may be some peer dependencies maybe?

robertpatrick commented 2 years ago

I have moved on to avoid the use of the axios module. Switching package managers seems like a workaround to the problem to me.

kissu commented 2 years ago

Not sure why a workaround. If NPM does the job poorly, eh can't blame on axios. 🤷🏻‍♂️

robertpatrick commented 2 years ago

npm works perfectly and in some ways, is ahead of yarn. The point is that your have published a package to registry.npmjs.org that doesn't work. By the way, axios works fine. It's the axios-module that's broken. Clearly, you don't care so...

kissu commented 2 years ago

npm works perfectly and in some ways, is ahead of yarn Highly debatable on a lot of points. Anyway, PNPM is better overall.

It's not my package tbh (I'm just a random user passing by on some issues), and here it looks like a dependency resolution more than anything else but eh, since you don't really care about the module itself: no need to tryhard.