[PR #25672] Bugfix: Windows compatibility issue with 'cp' command not found when running pnpm start. (#25670) #31161

Closed
opened 2026-02-21 20:48:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25672

State: closed
Merged: Yes


…ing pnpm start. (#25670)

  • Replace the existing start script in package.json with a reference to a new copy-and-start.mjs file
  • Add new copy-and-start.mjs script to handle copying static files and starting the server
  • Improve error handling and logging for the start process
  • Make the script more configurable with environment variables

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This PR addresses issue #25670 which fixes a Windows compatibility problem where the 'cp' command was not found when running pnpm start. The issue occurred because the original start script in package.json used Unix-specific cp commands that are not available on Windows systems.

To resolve this cross-platform compatibility issue, I've replaced the simple shell commands with a Node.js script (copy-and-start.mjs) that performs the same file copying operations using Node's built-in fs module, which works consistently across all platforms.

The new script:

  1. Copies static files from .next/static to .next/standalone/.next/static
  2. Copies public resources from public to .next/standalone/public
  3. Starts the server with configurable host and port via environment variables
  4. Includes proper error handling and logging

This change ensures that Dify web application can be built and started successfully on both Unix-like systems and Windows systems without requiring additional tools or shell compatibility layers.

Fixes #25670

Screenshots

Before After
image image

(Note: These are representative images showing the error that was occurring and the successful result after the fix)

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/25672 **State:** closed **Merged:** Yes --- …ing pnpm start. (#25670) - Replace the existing start script in package.json with a reference to a new copy-and-start.mjs file - Add new copy-and-start.mjs script to handle copying static files and starting the server - Improve error handling and logging for the start process - Make the script more configurable with environment variables > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary This PR addresses issue #25670 which fixes a Windows compatibility problem where the 'cp' command was not found when running `pnpm start`. The issue occurred because the original start script in package.json used Unix-specific `cp` commands that are not available on Windows systems. To resolve this cross-platform compatibility issue, I've replaced the simple shell commands with a Node.js script (`copy-and-start.mjs`) that performs the same file copying operations using Node's built-in `fs` module, which works consistently across all platforms. The new script: 1. Copies static files from `.next/static` to `.next/standalone/.next/static` 2. Copies public resources from `public` to `.next/standalone/public` 3. Starts the server with configurable host and port via environment variables 4. Includes proper error handling and logging This change ensures that Dify web application can be built and started successfully on both Unix-like systems and Windows systems without requiring additional tools or shell compatibility layers. Fixes #25670 ## Screenshots | Before | After | |--------|-------| | <img width="1088" height="172" alt="image" src="https://github.com/user-attachments/assets/b440f1b5-4b50-4f13-a417-0ea27bff59b2" /> | <img width="607" height="274" alt="image" src="https://github.com/user-attachments/assets/0149c2aa-92b8-4d4e-8e64-dbab80dc1ab0" /> | (Note: These are representative images showing the error that was occurring and the successful result after the fix) ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:48:56 -05:00
yindo closed this issue 2026-02-21 20:48:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31161