-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server imports lack the file extensions required by native esm #14597
Comments
@pi0 I can also reproduce this issue. |
Resolution: https://stackblitz.com/edit/nuxt-starter-zwu1fk?file=nuxt.config.ts,app.vue |
Added this options returns in other errors:
Other potential fix may be to add extension of the import module like: import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep.js' |
In |
Stack one also didn't work for me. Switching from rc.6 to rc.8 created this issue. I had this on my config export default defineNuxtConfig({
nitro: {
externals: {
inline: ["uuid", "lodash"],
},
},
}) now it doesn't seem to work. Did you figure it out @v-romanyuk ? |
For anyone wondering what the issue is? es6 modules like uiid needs to be transpiled. export default defineNuxtConfig({
build: {
transpile: ["uuid"],
},
}) Anything else must be commonjs and additionally folder import are no longer a thing You will need to especify the file for imports within libraries like so: import cloneDeep from "lodash/cloneDeep.js"; |
Same error here happened after switching from rc.6 to rc.8
|
@gezichenshan I just put a file extension in the import path for now. Not a big deal but still a bit inconvenient. |
@v-romanyuk I've tried to add lodash-es in the build -> transpile but nothing works. The issue originated that I want to use @pinia/nuxt in my nuxt3 project (3.0.0-rc.6). Then I encountered an issue that pinia says its peerDependency "vue-demi " isn't a common js module and didn't export the functions I want. So I follow the doc adding "vue-demi" into the build -> transpile but no help. |
exact same error here, Has anyone found any solution ? |
@alisdg @gezichenshan Use the commonjs module "lodash" and for file import add the .js file extension. Like this. This is not a nuxt issue but a intended nodejs package resolution feature. |
I'm getting the same lodash error when trying to run
|
I'm getting this with
Adding |
Using @nuxt/pinia |
That’s not the issue. I have that module already set up. And everything works great when using the dev server. I just wrote a script to add the .mjs after I build, which solves my problem for now. |
I'm not sure if this is relevant, but I was experiencing this component of this issue:
And changing my npm version to that of a collaborator (who was not experiencing this issue on the same, clean, repo) fixed this symptom. NVM: I don't know enough about nuxt to know if this is likely to be helpful for others, so I'm happy to delete this if it's not useful. |
Can you share that script ? I'm hanging now on the same issue. |
I just used #!/bin/sh
sed -i "s#pinia/dist/pinia'#pinia/dist/pinia.mjs'#g" .output/server/chunks/_..._.mjs
sed -i "s#pinia/dist/pinia'#pinia/dist/pinia.mjs'#g" .output/server/chunks/_orders.mjs |
I'm getting this error in webpack mode even though I've got
export default defineNuxtConfig({
alias: {
'~': path.resolve(__dirname, 'node_modules'),
'@/': path.resolve(__dirname, 'src')
},
vite: false,
webpack: {
resolve: {
extensions: [
".js",
".vue",
".mjs"
]
}
},
extensions: [
".js",
".vue",
".mjs"
] |
I tried adding file extensions, but then I get this...
|
The original reproduction is no longer reproducible for me with Nitro 0.6.1: https://stackblitz.com/edit/nuxt-starter-shejcp. If someone is still experiencing a similar problem, please open a new issue with a reproduction and I will address. |
Environment
Darwin
v16.15.1
3.0.0-rc.8
yarn@1.22.19
vite
-
-
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-a2yhjt?file=app.vue
Describe the bug
Importing anything from the node_modules without explicit extension will return an error that module is not found. Here is the example of importing a function from lodash. However if I import it with the explicit extension like 'lodash/cloneDeep.js' everything works well.
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: