Named export 'provider' not found - std-env
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v14.17.1
- Nuxt Version:
3.0.0-27496606.e43ba6e
- Package Manager:
yarn@1.22.18
- Builder:
vite
- User Config:
head
,css
,build
,modules
,buildModules
,components
,runtimeConfig
,strapi
- Runtime Modules:
@nuxtjs/tailwindcss@5.0.2
- Build Modules:
@vueuse/nuxt@8.2.5
,@nuxtjs/strapi@1.3.1
,@unlighthouse/nuxt@0.3.21
Reproduction
Can’t reproduce
Describe the bug
Error in console caused by std-env
ERROR [worker reload] [worker init] Named export ‘provider’ not found. The requested module ‘file:///home/user/Documents/GitHub/project-name/node_modules/std-env/index.js’ is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from ‘file:///home/user/Documents/GitHub/project-name/node_modules/std-env/index.js’; const { provider, isWindows } = pkg;
import { provider, isWindows } from ‘node_modules/std-env/index.js’; ^^^^^^^^ SyntaxError: Named export ‘provider’ not found. The requested module ‘node_modules/std-env/index.js’ is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from ‘node_modules/std-env/index.js’; const { provider, isWindows } = pkg;
Additional context
I’ve already tried the following solutions:
- Running
npx nuxi upgrade --force
(as suggested in nuxt/bridge#175) - Removing
@nuxtjs/strapi
- Upgrading Nuxt to the latest version using
npx nuxi upgrade
- Adding
std-env
to devDependencies (as suggested in nuxt/bridge#175) causes the error to become:
[worker reload] [worker init] Cannot find module ‘/home/user/Documents/GitHub/project-name/node_modules/std-env/index.js’ imported from /home/user/Documents/GitHub/project-name/.nuxt/dev/index.mjs
at finalizeResolution (internal/modules/esm/resolve.js:271:11) at moduleResolve (internal/modules/esm/resolve.js:694:10) at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:805:11) at Loader.resolve (internal/modules/esm/loader.js:88:40) at Loader.getModuleJob (internal/modules/esm/loader.js:241:28) at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:72:40) at link (internal/modules/esm/module_job.js:71:36)
By looking inside the yarn.lock
I found two versions of std-env
, ^2.3.0
and ^3.0.1
, the first one is being used by "@nuxt/cli@^2.15.8"
and "@nuxt/config@2.15.8"
Also if I visit the local server I still get the error reported in nuxt/framework#4274
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
Thanks for reporting the issue @Redemption198. For future reference, this was due to the module having a @nuxt/cli dependency, it was using one of the exported utility functions
I just discovered that there is a bug inside the Nuxt Strapi module as described here and this pull request should solve it.