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

Buid giving the error in cloudflare-pages preset #129

Closed
been-there-done-that opened this issue Aug 8, 2023 · 12 comments
Closed

Buid giving the error in cloudflare-pages preset #129

been-there-done-that opened this issue Aug 8, 2023 · 12 comments

Comments

@been-there-done-that
Copy link

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/[email protected]/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/[email protected]/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

@been-there-done-that been-there-done-that changed the title Buidl giving the error in cloudflare-pages preset Buid giving the error in cloudflare-pages preset Aug 8, 2023
@pi0 pi0 closed this as completed in d24e470 Aug 8, 2023
@pi0
Copy link
Member

pi0 commented Aug 8, 2023

Thanks for reporting!

@been-there-done-that
Copy link
Author

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/[email protected]/node_modules/unenv/runtime/node/fs/promises/index.mjs", imported by "node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/unenv/runtime/node/fs/promises/index.mjs", imported by "node_modules/.pnpm/[email protected]/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)

@pi0
Copy link
Member

pi0 commented Aug 8, 2023

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)

@been-there-done-that
Copy link
Author

Sure let me check and see if share you a reproduction.

@been-there-done-that
Copy link
Author

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.

@pi0
Copy link
Member

pi0 commented Aug 8, 2023

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)

@been-there-done-that
Copy link
Author

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/[email protected]/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/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
  at Module.error (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:13604:16)
  at Module.traceVariable (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:14029:29)
  at ModuleScope.findVariable (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:12547:39)
  at ChildScope.findVariable (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
  at ClassBodyScope.findVariable (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)
  at ChildScope.findVariable (/C:/projects/<>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7082:38)

getting the following error from windows i hope this also helps.

@been-there-done-that
Copy link
Author

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

@andrevandal
Copy link

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/[email protected]/node_modules/readable-stream/lib/_stream_readable.js using exports defined in /Users/andre.vandal/projects/github.com/andrevandal/ondevamos-web/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/node_modules/readable-stream/lib/_stream_readable.js" and externals are not allowed!

  at Object.resolveId (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nitropack/dist/shared/nitro.0093b44c.mjs:1879:17)
  at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
  at async resolveId (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24117:26)
  at async ModuleLoader.resolveId (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24531:15)
  at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
  at async resolveId (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24117:26)
  at async ModuleLoader.resolveId (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24531:15)
  at async node_modules/.pnpm/@[email protected][email protected]/node_modules/@rollup/plugin-commonjs/dist/es/index.js:781:16
  at async Promise.all (index 10)
  at async node_modules/.pnpm/@[email protected][email protected]/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/[email protected]/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

@pi0
Copy link
Member

pi0 commented Oct 11, 2023

@andrevandal Do you mind to reopen a new issue in nitro/nuxt with same description so not forget to check on this? 🙏🏼

@andrevandal
Copy link

@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

@saeedkgr
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants