question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Named export 'provider' not found - std-env

See original GitHub issue

Environment


  • 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:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
harlan-zwcommented, Apr 20, 2022

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

0reactions
Redemption198commented, Apr 13, 2022

I just discovered that there is a bug inside the Nuxt Strapi module as described here and this pull request should solve it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nixpkgs 22.11 manual - NixOS
Nix expressions describe how to build packages from source and are collected in the nixpkgs repository. Also included in the collection are Nix...
Read more >
Named export 'Types' not found. The requested module ...
The requested module 'mongoose' is a CommonJS module, which may not support all module. exports as named exports. Save this question.
Read more >
The build Property - Nuxt
Nuxt lets you customize the webpack configuration for building your web application as you want.
Read more >
Nuxt3にBridgeを使って移行してみる【Nuxt2→3】 - t8
WARN [worker] Named export 'isWindows' not found. The requested module 'std-env' is a CommonJS module, which may not support all ...
Read more >
Appendix A. Configuration Options - GitLab
When this indicates a specific provider then, for example, the IMAP, SMTP, ... Input methods is a software to input symbols that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found