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

Error building my application #1414

Open
zeneiltongpdev opened this issue Mar 2, 2025 · 12 comments
Open

Error building my application #1414

zeneiltongpdev opened this issue Mar 2, 2025 · 12 comments

Comments

@zeneiltongpdev
Copy link

Describe the bug

✘ [ERROR] Build failed with 5 errors:

  ✘ [ERROR] Could not resolve "child_process"

      ../build/server/index.js:25:31:
        25 │ import { execSync, exec } from 'child_process';
           ╵                                ~~~~~~~~~~~~~~~

    The package "child_process" wasn't found on the file system but is built into node. Are you
  trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this
  error.


  ✘ [ERROR] Could not resolve "crypto"

      ../build/server/index.js:29:19:
        29 │ import crypto from 'crypto';
           ╵                    ~~~~~~~~

    The package "crypto" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


  ✘ [ERROR] Could not resolve "util"

      ../build/server/index.js:31:26:
        31 │ import { promisify } from 'util';
           ╵                           ~~~~~~

    The package "util" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


  ✘ [ERROR] Could not resolve "crypto"

      ../node_modules/.pnpm/[email protected]/node_modules/cookie-signature/index.js:5:21:
        5 │ var crypto = require('crypto');
          ╵                      ~~~~~~~~

    The package "crypto" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


  ✘ [ERROR] Could not resolve "stream"

      ../node_modules/.pnpm/[email protected]/node_modules/stream-slice/index.js:3:24:
        3 │ var Transform = require('stream').Transform;
          ╵                         ~~~~~~~~

    The package "stream" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


✘ [ERROR] Failed to build Functions at ./functions.


🪵  Logs were written to "/home/bolt/.config/.wrangler/logs/wrangler-2025-03-02_01-55-15_331.log"
 ELIFECYCLE  Command failed with exit code 1.

Link to the Bolt URL that caused the error

https://github.com/stackblitz-labs/bolt.diy/releases/tag/v0.0.7

Steps to reproduce

pnpm run build && pnpm run start

Expected behavior

Complete build

Screen Recording / Screenshot

No response

Platform

  • OS: [Linux - Ubuntu 24.04]
  • Browser: [Chrome]
  • Version: [0.0.7]

Provider Used

No response

Model Used

No response

Additional context

No response

@kamilfurtak
Copy link

Try running app with pnpm run dev command as shown in https://github.com/stackblitz-labs/bolt.diy?tab=readme-ov-file#running-the-application
There is a problem with running it using the wrangler dev command, I described this issue here in the context of Docker at #1316 (comment)

@zeneiltongpdev
Copy link
Author

Try running app with pnpm run dev command as shown in https://github.com/stackblitz-labs/bolt.diy?tab=readme-ov-file#running-the-application There is a problem with running it using the wrangler dev command, I described this issue here in the context of Docker at #1316 (comment)

My need is really this, to build my application and make it available on my VPS. I did this with version 0.0.6 following the DIY Smart Code - @leex279 tutorial which worked super well, but now when I try to update following the same steps, I can't make it work.

Any help?

Image

@morningxm
Copy link

I also faced this issue, please help me.

@zeneiltongpdev
Copy link
Author

I also faced this issue, please help me. @morningxm

I'm going to do some new experiments today, including setting up the Wrangler to see if it works.

@leex279
Copy link
Collaborator

leex279 commented Mar 3, 2025

Hi all,
I also spent hours already on trying to get it deployed again on Cloudflare with Workers, Pages, but so far it did not work :/

Currently I try with Workers, but I stuck at this at the end:

Image

@morningxm
Copy link

I found it is impossible to use child_process on non-Node runtime like Cloudflare pages. I think it is the solution to remove app-info and git-info from Settings.

Image

@leex279
Copy link
Collaborator

leex279 commented Mar 3, 2025

but the "child-process" is used in more files and removing these files will break features.

@leex279
Copy link
Collaborator

leex279 commented Mar 3, 2025

@Stijnus @xKevIsDev @thecodacus Can we replace this child-process thing with something other or make it more optional to make the cloudflare/VPS deployment work again?

@morningxm
Copy link

morningxm commented Mar 3, 2025

@leex279 , I have removed app-info, git-info, update sections from Setting panel. so I resolved the issues with child_process, crypto, stream, util

patch api.deploy.ts 104-109

// remove import crypto
    for (const [filePath, content] of Object.entries(files)) {
      // Ensure file path starts with a forward slash
      const normalizedPath = filePath.startsWith('/') ? filePath : '/' + filePath;
      const hash = crypto.createHash('sha1').update(content).digest('hex');
      fileDigests[normalizedPath] = hash;
    }

to

    for (const [filePath, content] of Object.entries(files)) {
      // Ensure file path starts with a forward slash
      const normalizedPath = filePath.startsWith('/') ? filePath : '/' + filePath;

      // Generate SHA-1 hash using the Web Crypto API
      const encoder = new TextEncoder();
      const data = encoder.encode(content);
      const hashBuffer = await crypto.subtle.digest('SHA-1', data);
      const hashArray = Array.from(new Uint8Array(hashBuffer));
      const hashHex = hashArray.map((byte) => byte.toString(16).padStart(2, '0')).join('');

      fileDigests[normalizedPath] = hashHex;
    }

but now I have another issue

Image

Stijnus added a commit to Stijnus/bolt.diy that referenced this issue Mar 3, 2025
@Stijnus
Copy link
Collaborator

Stijnus commented Mar 3, 2025

could you test : #1436

@leex279
Copy link
Collaborator

leex279 commented Mar 3, 2025

@morningxm yeah, got the same with the PR from @Stijnus. But I am confident he will find a solution for this as well :)

@Tryanks
Copy link

Tryanks commented Mar 4, 2025

could you test : #1436

Hi, just for reference, I was able to run production via PR #1436. This change effectively resolved my issue without needing to run in dev mode.

Here's the detailed process description:

I simply pulled the latest released version v0.0.7:

git clone https://github.com/stackblitz-labs/bolt.diy.git -b v0.0.7 --depth 1

Then, I built it directly:

docker build -t bolt-ai:production -t bolt-ai:latest --target bolt-ai-production .

Next, I ran it using compose:

cp .env.example .env.local
docker compose --profile production up

Then I encountered the following error related to wranger :(

❯ docker compose --profile production up
[+] Running 2/2
 ✔ Network boltdiy_default       Created                                                                                     0.1s 
 ✔ Container boltdiy-app-prod-1  Created                                                                                     0.1s 
Attaching to app-prod-1
app-prod-1  | 
app-prod-1  | > [email protected] dockerstart /app
app-prod-1  | > bindings=$(./bindings.sh) && wrangler pages dev ./build/client $bindings --ip 0.0.0.0 --port 5173 --no-show-interactive-dev-session
app-prod-1  | 
app-prod-1  | 
app-prod-1  |  ⛅️ wrangler 3.108.0
app-prod-1  | --------------------
app-prod-1  | 
app-prod-1  | ✘ [ERROR] Build failed with 5 errors:
app-prod-1  | 
app-prod-1  |   ✘ [ERROR] Could not resolve "child_process"
app-prod-1  |   
app-prod-1  |       ../build/server/index.js:25:31:
app-prod-1  |         25 │ import { execSync, exec } from 'child_process';
app-prod-1  |            ╵                                ~~~~~~~~~~~~~~~
app-prod-1  |   
app-prod-1  |     The package "child_process" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
app-prod-1  |   
app-prod-1  |   
app-prod-1  |   ✘ [ERROR] Could not resolve "crypto"
app-prod-1  |   
app-prod-1  |       ../build/server/index.js:29:19:
app-prod-1  |         29 │ import crypto from 'crypto';
app-prod-1  |            ╵                    ~~~~~~~~
app-prod-1  |   
app-prod-1  |     The package "crypto" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
app-prod-1  |   
app-prod-1  |   
app-prod-1  |   ✘ [ERROR] Could not resolve "util"
app-prod-1  |   
app-prod-1  |       ../build/server/index.js:31:26:
app-prod-1  |         31 │ import { promisify } from 'util';
app-prod-1  |            ╵                           ~~~~~~
app-prod-1  |   
app-prod-1  |     The package "util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
app-prod-1  |   
app-prod-1  |   
app-prod-1  |   ✘ [ERROR] Could not resolve "crypto"
app-prod-1  |   
app-prod-1  |       ../node_modules/.pnpm/[email protected]/node_modules/cookie-signature/index.js:5:21:
app-prod-1  |         5 │ var crypto = require('crypto');
app-prod-1  |           ╵                      ~~~~~~~~
app-prod-1  |   
app-prod-1  |     The package "crypto" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
app-prod-1  |   
app-prod-1  |   
app-prod-1  |   ✘ [ERROR] Could not resolve "stream"
app-prod-1  |   
app-prod-1  |       ../node_modules/.pnpm/[email protected]/node_modules/stream-slice/index.js:3:24:
app-prod-1  |         3 │ var Transform = require('stream').Transform;
app-prod-1  |           ╵                         ~~~~~~~~
app-prod-1  |   
app-prod-1  |     The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
app-prod-1  |   
app-prod-1  |   
app-prod-1  | 
app-prod-1  | 
app-prod-1  | 
app-prod-1  | ✘ [ERROR] Failed to build Functions at ./functions.
app-prod-1  | 
app-prod-1  | 
app-prod-1  | 🪵  Logs were written to "/root/.config/.wrangler/logs/wrangler-2025-03-04_04-42-48_679.log"
app-prod-1  |  ELIFECYCLE  Command failed with exit code 1.
app-prod-1 exited with code 1

At this point, the only solution was to rebuild the development version.

However, with the latest PR #1436, I was able to follow the steps above again and successfully run it directly:

❯ docker compose --profile production up
[+] Running 1/1
 ✔ Container boltdiy-app-prod-1  Recreated                                                                                   0.1s 
Attaching to app-prod-1
app-prod-1  | 
app-prod-1  | > [email protected] dockerstart /app
app-prod-1  | > bindings=$(./bindings.sh) && wrangler pages dev ./build/client $bindings --ip 0.0.0.0 --port 5173 --no-show-interactive-dev-session
app-prod-1  | 
app-prod-1  | 
app-prod-1  |  ⛅️ wrangler 3.108.0
app-prod-1  | --------------------
app-prod-1  | 
app-prod-1  | ✨ Compiled Worker successfully
app-prod-1  | Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
app-prod-1  | 
app-prod-1  | Your worker has access to the following bindings:
app-prod-1  | - Vars:
app-prod-1  |   - RUNNING_IN_DOCKER: "(hidden)"
app-prod-1  |   - DEFAULT_NUM_CTX: "(hidden)"
app-prod-1  | [wrangler:inf] Ready on http://0.0.0.0:5173
app-prod-1  | [wrangler:inf] - http://127.0.0.1:5173
app-prod-1  | ⎔ Starting local server...

Overall, in my test case, this PR works!

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

6 participants