apollo
apollo copied to clipboard
build with nuxt3 not find tslib
Environment
Nuxi 3.5.3 7:32:45 PM
7:32:45 PM
RootDir: /Users/naco/Documents/retain 7:32:45 PM
Nuxt project info: (copied to clipboard) 7:32:45 PM
------------------------------
- Operating System: Darwin
- Node Version: v18.16.0
- Nuxt Version: 3.5.3
- Nitro Version: 2.4.1
- Package Manager: [email protected]
- Builder: vite
- User Config: app, devtools, srcDir, modules, imports, pinia, alias, apollo
- Runtime Modules: @nuxtjs/[email protected], @pinia/[email protected]
- Build Modules: -
------------------------------
👉 Report an issue: https://github.com/nuxt/nuxt/issues/new 7:32:45 PM
👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new
👉 Read documentation: https://nuxt.com
Describe the bug
naco@NaCo retain % node .output/server/index.mjs
Listening http://[::]:3000
[nuxt] [request error] [unhandled] [500] Cannot find module '/Users/naco/Documents/retain/.output/server/node_modules/tslib/modules/index.js' imported from /Users/naco/Documents/retain/.output/server/chunks/app/server.mjs
Did you mean to import tslib/tslib.js?
at new NodeError (node:internal/errors:399:5)
at finalizeResolution (node:internal/modules/esm/resolve:326:11)
at moduleResolve (node:internal/modules/esm/resolve:945:10)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
Expected behaviour
nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
head: {
charset: 'utf-8',
viewport: 'width=device-width, initial-scale=1',
}
},
devtools: { enabled: true },
srcDir:"./src",
modules: ['@nuxtjs/apollo','@pinia/nuxt'],
imports: {
dirs: ['./store'],
},
pinia: {
autoImports: ['defineStore', 'acceptHMRUpdate','storeToRefs'],
},
alias: {
tslib: 'tslib'
},
apollo: {
clients: {
default: {
httpEndpoint: 'https://api.nco.im/graphql'
}
},
},
})
Reproduction
No response
Additional context
No response
Logs
No response
Likely due to this change to tslib
exports, you can override the version to one that works
PNPM
{
"pnpm": {
"overrides": {
"tslib": "2.5.1"
}
}
}
Yarn
{
"resolutions": {
"tslib": "2.5.1"
}
}
@slavanossar thx bro.
@NaCoLiu I think leave this issue open, this module might need to be updated to use new exports from tslib
so the issue needs to be tracked
@slavanossar any resolution for npm?
@oosame you can try pinning the version by adding the required version as a dependency
npm install [email protected] --save-dev
@oosame you can try pinning the version by adding the required version as a dependency
npm install [email protected] --save-dev
thx bro.
Also need to check that package.json has "type": "module"
@slavanossar any resolution for npm?
{
"overrides": {
"tslib": "2.5.1"
}
}
Related issues:
- https://github.com/nuxt/nuxt/issues/19265
- https://github.com/vueuse/motion/issues/102
- https://github.com/nuxt-modules/apollo/issues/516
Any updates on this? It'd be nice if this gets fixed in v5 and we could use the latest version tslib, since some other libraries need it.
@Sina-Afsharmanesh check one of these solutions. Both should work.
https://github.com/nuxt/nuxt/issues/19265#issuecomment-1702014262
just add to nuxt config
build: {
transpile: ['tslib']
}