dify icon indicating copy to clipboard operation
dify copied to clipboard

Enhance npm Start Script for Windows Compatibility

Open chiragksharma opened this issue 1 year ago • 1 comments

Self Checks

  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] Pleas do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing?

Yes, the current npm start script utilizes commands that are not compatible with Windows environments, specifically the Unix cp command. This results in errors like 'cp' is not recognized as an internal or external command, operable program or batch file. when developers on Windows attempt to run the script.

2. Describe the feature you'd like to see

I propose to modify the npm start script to use cross-platform compatible commands, ensuring it runs smoothly on both Windows and Unix-like systems. This involves replacing Unix-specific commands with the shx command utility, which mimics Unix commands in a cross-platform way.

3. How will this feature improve your workflow or experience?

  1. Eliminate OS-specific errors
  2. Standardize development practices
  3. Reduce setup time and confusion

4. Additional context or comments

Modify the start Script

Update the start script in package.json to use shx for the copy operations. Here’s how you can modify it:

{
  "scripts": {
    "start": "shx cp -r .next/static .next/standalone/.next/static && shx cp -r public .next/standalone/public && cross-env PORT=$npm_config_port HOSTNAME=$npm_config_host node .next/standalone/server.js"
  }
}

5. Can you help us with this feature?

  • [X] I am interested in contributing to this feature.

chiragksharma avatar Apr 13 '24 18:04 chiragksharma

In this case, I suggest using WSL instead of the raw windows command.

crazywoola avatar Apr 14 '24 01:04 crazywoola

Worked thanks 👍

chiragksharma avatar Apr 23 '24 14:04 chiragksharma