Buid giving the error in `cloudflare-pages` preset
been-there-done-that opened this issue Β· comments
Environment
Cloudflare-pages
Reproduction
NITRO_PRESET='cloudflare-pages' npm run build
Describe the bug
Unable to build in cloudflare-pages preset.
The same working with normal nodejs preset.
NITRO_PRESET='cloudflare-pages' npm run build
Can someone please guide me what is the issue and how to resolve this.
Additional context
βΉ β built in 99ms 8:00:42 PM
β Server built in 187ms 8:00:42 PM
β Generated public dist nitro 8:00:45 PM
βΉ Building Nitro Server (preset: cloudflare-pages) nitro 8:00:45 PM
[nitro 8:00:48 PM] ERROR Error: Cannot resolve "src/runtime/_internal/utils" from "/Users/<>/projects/data_builds/<>/<>/clloud_pages/<>/node_modules/.pnpm/unenv@1.7.0/node_modules/unenv/runtime/node/string_decoder/index.mjs" and externals are not allowed!
undefined
[8:00:48 PM] ERROR Cannot resolve "src/runtime/_internal/utils" from "/Users/<>/projects/data_builds/<>/<>/clloud_pages/<>/node_modules/.pnpm/unenv@1.7.0/node_modules/unenv/runtime/node/string_decoder/index.mjs" and externals are not allowed!
at Object.resolveId (node_modules/.pnpm/nitropack@2.5.2_@planetscale+database@1.10.0/node_modules/nitropack/dist/shared/nitro.7a525996.mjs:1781:17)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:25256:28)
at async resolveId (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:23931:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:24345:15)
at async Object.resolveId (node_modules/.pnpm/@rollup+plugin-commonjs@25.0.3_rollup@3.27.2/node_modules/@rollup/plugin-commonjs/dist/es/index.js:581:10)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:25256:28)
at async resolveId (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:23931:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:24345:15)
at async node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:24636:50
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Logs
No response
Thanks for reporting!
Hi @pi0
Updated the unenv version and now getting the following error.
[nitro 8:53:38 PM] ERROR RollupError: "default" is not exported by "node_modules/.pnpm/unenv@1.7.1/node_modules/unenv/runtime/node/fs/promises/index.mjs", imported by "node_modules/.pnpm/formidable@3.5.0/node_modules/formidable/src/Formidable.js".
4: import os from 'node:os';
5: import path from 'node:path';
6: import fsPromises from 'node:fs/promises';
^
7: import { EventEmitter } from 'node:events';
8: import { StringDecoder } from 'node:string_decoder';
ERROR "default" is not exported by "node_modules/.pnpm/unenv@1.7.1/node_modules/unenv/runtime/node/fs/promises/index.mjs", imported by "node_modules/.pnpm/formidable@3.5.0/node_modules/formidable/src/Formidable.js". 8:53:38 PM
at error (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
at Module.error (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:13604:16)
at Module.traceVariable (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:14029:29)
at ModuleScope.findVariable (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:12547:39)
at FunctionScope.findVariable (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
at ChildScope.findVariable (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
at MemberExpression.bind (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:9482:49)
at CallExpression.bind (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5850:23)
at CallExpression.bind (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:9833:15)
at ReturnStatement.bind (node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:5850:23)
Although this is not related to any recent change, seems something valid to be supported.
Can you by any chances share me a reproduction? (i made fix in 37fd173 but need to make sure it is valid)
Sure let me check and see if share you a reproduction.
how can i checkout to this specific commit in my local and test it out.
as my project is a private repo there are a lot of dependencies sorry unable to share a reproduction.
If you are able to help me get into local will be able to test it out ASAP.
Thanks.
No worries if too much trouble on reproduction i will go ahead and directly release shortly. (i was mostly curious what dependencies are pulling this apis. until now, it was hidden issue because we used silent mocks)
tried do in windows machine
[nitro 11:40:11 PM] ERROR RollupError: "createHash" is not exported by "node_modules/unenv/runtime/node/crypto/index.mjs", imported by "node_modules/.pnpm/formidable@3.5.0/node_modules/formidable/src/VolatileFile.js".
1: /* eslint-disable no-underscore-dangle */
2:
3: import { createHash } from 'node:crypto';
^
4: import { EventEmitter } from 'node:events';
[11:40:11 PM] ERROR "createHash" is not exported by "node_modules/unenv/runtime/node/crypto/index.mjs", imported by "node_modules/.pnpm/formidable@3.5.0/node_modules/formidable/src/VolatileFile.js".
at error (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
at Module.error (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:13604:16)
at Module.traceVariable (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:14029:29)
at ModuleScope.findVariable (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:12547:39)
at ChildScope.findVariable (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
at ClassBodyScope.findVariable (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
at ChildScope.findVariable (/C:/projects/<>/node_modules/.pnpm/rollup@3.27.2/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
getting the following error from windows i hope this also helps.
Found the culprit
import { readFiles } from "h3-formidable";
import * as fs from "fs";
For future reference for anyone did the following
pnpm why unenv
went through just the one are potential causes and tried it out
during testing was writing the files to the local disk so was using h3-formidable that's what caused the issue.
I am so sorry about the last issue.
I appreciate the time and effort you put into every single commit.
Cheer's
hello @pi0, sorry for opening this issue again but I'm facing a related problem.
I'm crafting an app to find places using nuxt, nitro, cloudflare pages, drizzle and planetscale.
the dev env is working, but once I build, I got the following error:
β Server built in 1675ms 8:37:59 PM
β Generated public dist nitro 8:37:59 PM
βΉ Building Nitro Server (preset: cloudflare_pages) nitro 8:37:59 PM
(node-resolve plugin) Could not resolve import "unenv/runtime/node/string_decoder/index/" in /Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js using exports defined in /Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/unenv@1.7.4/node_modules/unenv/package.json.
[nitro 8:38:02 PM] ERROR Error: Cannot resolve "unenv/runtime/node/string_decoder/index/" from "/Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js" and externals are not allowed!
undefined
[8:38:02 PM] ERROR Cannot resolve "unenv/runtime/node/string_decoder/index/" from "/Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js" and externals are not allowed!
at Object.resolveId (node_modules/.pnpm/nitropack@2.6.3_@planetscale+database@1.11.0/node_modules/nitropack/dist/shared/nitro.0093b44c.mjs:1879:17)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
at async resolveId (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24117:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24531:15)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
at async resolveId (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24117:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24531:15)
at async node_modules/.pnpm/@rollup+plugin-commonjs@25.0.5_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:781:16
at async Promise.all (index 10)
at async node_modules/.pnpm/@rollup+plugin-commonjs@25.0.5_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:773:32
[8:38:02 PM] ERROR Cannot resolve "unenv/runtime/node/string_decoder/index/" from "/Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js" and externals are not allowed!
βELIFECYCLEβ Command failed with exit code 1.
some deps:
"devDependencies": {
"@nuxtjs/tailwindcss": "6.8.0",
"drizzle-kit": "0.19.13",
"nuxt": "3.7.4",
},
"dependencies": {
"@planetscale/database": "1.11.0",
"drizzle-orm": "0.28.6",
}
running pnpm why unenv
, I got:
dependencies:
h3-zod 0.5.1
βββ¬ h3 1.8.2 peer
βββ unenv 1.7.4
devDependencies:
@nuxt/devtools 1.0.0-beta.0
βββ¬ @nuxt/devtools-kit 1.0.0-beta.0
β βββ¬ nuxt 3.7.4 peer
β βββ¬ @nuxt/vite-builder 3.7.4
β β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ nitropack 2.6.3
β β βββ¬ h3 1.8.2
β β β βββ unenv 1.7.4
β β βββ¬ listhen 1.5.5
β β β βββ¬ h3 1.8.2
β β β βββ unenv 1.7.4
β β βββ unenv 1.7.4
β β βββ¬ unstorage 1.9.0
β β βββ¬ h3 1.8.2
β β β βββ unenv 1.7.4
β β βββ¬ listhen 1.5.5
β β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ unenv 1.7.4
βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ nuxt 3.7.4 peer
βββ¬ @nuxt/vite-builder 3.7.4
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ nitropack 2.6.3
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ unenv 1.7.4
β βββ¬ unstorage 1.9.0
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ unenv 1.7.4
@nuxtjs/tailwindcss 6.8.0
βββ¬ h3 1.8.2
βββ unenv 1.7.4
@vueuse/nuxt 10.5.0
βββ¬ nuxt 3.7.4 peer
βββ¬ @nuxt/vite-builder 3.7.4
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ nitropack 2.6.3
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ unenv 1.7.4
β βββ¬ unstorage 1.9.0
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ unenv 1.7.4
nuxt 3.7.4
βββ¬ @nuxt/vite-builder 3.7.4
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ¬ nitropack 2.6.3
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ unenv 1.7.4
β βββ¬ unstorage 1.9.0
β βββ¬ h3 1.8.2
β β βββ unenv 1.7.4
β βββ¬ listhen 1.5.5
β βββ¬ h3 1.8.2
β βββ unenv 1.7.4
βββ unenv 1.7.4
I guess I'm using the latest version of unenv.
as the app is open source, you can check the repository.
I don't know how to create a scenario to allow you to reproduce the behavior.
could you help me?
thanks
@andrevandal Do you mind to reopen a new issue in nitro/nuxt with same description so not forget to check on this? ππΌ
@andrevandal Do you mind to reopen a new issue in nitro/nuxt with same description so not forget to check on this? ππΌ
sure, done: unjs/nitro#1821
same error different module
non of above solve the problem
βΉ Building Nitro Server (preset: cloudflare-pages) nitro 9:43:40 PM
(node-resolve plugin) Could not resolve import "unenv/runtime/node/string_decoder/index/" in D:\source\BP\webApps\app\node_modules\unzipper\node_modules\readable-stream\lib_stream_readable.js using exports defined in D:\source\BP\webApps\app\node_modules\unenv\package.json.
[nitro 9:43:41 PM] ERROR Error: Cannot resolve "unenv/runtime/node/string_decoder/index/" from "D:\source\BP\webApps\app\node_modules\unzipper\node_modules\readable-stream\lib\_stream_readable.js" and externals are not allowed!
undefined
[9:43:41 PM] ERROR Cannot resolve "unenv/runtime/node/string_decoder/index/" from "D:\source\BP\webApps\app\node_modules\unzipper\node_modules\readable-stream\lib\_stream_readable.js" and externals are not allowed!
at Object.resolveId (/D:/source/BP/webApps/app/node_modules/nitropack/dist/shared/nitro.4ea992bc.mjs:1973:17)
at async PluginDriver.hookFirstAndGetPlugin (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:18592:28)
at async resolveId (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:17261:26)
at async ModuleLoader.resolveId (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:17675:15)
at async PluginDriver.hookFirstAndGetPlugin (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:18592:28)
at async resolveId (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:17261:26)
at async ModuleLoader.resolveId (/D:/source/BP/webApps/app/node_modules/rollup/dist/es/shared/node-entry.js:17675:15)
at async /D:/source/BP/webApps/app/node_modules/@rollup/plugin-commonjs/dist/es/index.js:785:16
at async Promise.all (index 11)
at async /D:/source/BP/webApps/app/node_modules/@rollup/plugin-commonjs/dist/es/index.js:777:32
[9:43:41 PM] ERROR Cannot resolve "unenv/runtime/node/string_decoder/index/" from "D:\source\BP\webApps\app\node_modules\unzipper\node_modules\readable-stream\lib\_stream_readable.js" and externals are not allowed!
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.