Skip to content
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

LogLevels is not exported #350

Open
robokozo opened this issue Feb 13, 2025 · 3 comments
Open

LogLevels is not exported #350

robokozo opened this issue Feb 13, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@robokozo
Copy link

robokozo commented Feb 13, 2025

Environment

Node: 18.20.3
NPM: 10.2.3

Reproduction

https://stackblitz.com/edit/github-zsdq7msk?file=server%2Froutes%2Findex.ts

In the terminal type npm run build

Describe the bug

In a nitro project if you import LogLevels and then npm run build you get a fail with the following error

✔ Generated public .output/public                              nitro 9:19:46 PM
[nitro 9:19:47 PM] ℹ Building Nitro Server (preset: node-server, compatibility date: 2025-02-06)

[nitro 9:19:50 PM]  ERROR  RollupError: server/routes/index.ts (1:0): "LogLevels" is not exported by "node_modules/unenv/runtime/npm/consola.mjs", imported by "server/routes/index.ts".


1: import { LogLevels } from 'consola';
   ^
2: 
3: export default eventHandler((event) => {


[9:19:50 PM]  ERROR  server/routes/index.ts (1:0): "LogLevels" is not exported by "node_modules/unenv/runtime/npm/consola.mjs", imported by "server/routes/index.ts".

    at getRollupError (node_modules/rollup/dist/es/shared/parseAst.js:560:41)
    at Module.error (node_modules/rollup/dist/es/shared/parseAst.js:556:42)
    at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:16635:29)
    at Module.traceVariable (node_modules/rollup/dist/es/shared/node-entry.js:17084:29)
    at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:14741:39)
    at ReturnValueScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:5602:38)
    at FunctionBodyScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:5602:38)
    at MemberExpression.bind (node_modules/rollup/dist/es/shared/node-entry.js:7305:49)
    at ReturnStatement.bind (node_modules/rollup/dist/es/shared/node-entry.js:2799:23)
    at BlockStatement.bind (node_modules/rollup/dist/es/shared/node-entry.js:2795:28) 



[9:19:50 PM]  ERROR  server/routes/index.ts (1:0): "LogLevels" is not exported by "node_modules/unenv/runtime/npm/consola.mjs", imported by "server/routes/index.ts".

Additional context

My main motivation is to be able to set the console level with the log level 'word'

const consola = createConsola({
  level: LogLevels[process.env.logLevelWord]
})

VSCode understands the import and doesn't complain.

Logs

@robokozo robokozo added the bug Something isn't working label Feb 13, 2025
@sscotth
Copy link

sscotth commented Feb 14, 2025

That stackblitz works for me

Image Image

@robokozo
Copy link
Author

That stackblitz works for me

Image Image

The build process is what is failing

@sscotth
Copy link

sscotth commented Feb 15, 2025

Looks unenv specific

Try import { LogLevels } from 'consola/core'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants