langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
46.73k stars 6.61k forks source link

I use 'Start with Local Source Code',but npm install is error. #5650

Closed ganggangtian closed 3 months ago

ganggangtian commented 3 months ago

Self Checks

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

my os :Linux iZuf6fksh2blifag87jb4pZ 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux I use 'Start with Local Source Code',but npm install is error.

✔️ Expected Behavior

11

❌ Actual Behavior

(base) [root@iZuf6fksh2blifag87jb4pZ web]# npm install
npm WARN deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm WARN deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-darwin-arm64@14.2.4 (node_modules/next/node_modules/@next/swc-darwin-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-darwin-arm64@14.2.4: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-linux-arm64-gnu@14.2.4 (node_modules/next/node_modules/@next/swc-linux-arm64-gnu):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-linux-arm64-gnu@14.2.4: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-darwin-x64@14.2.4 (node_modules/next/node_modules/@next/swc-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-darwin-x64@14.2.4: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-linux-arm64-musl@14.2.4 (node_modules/next/node_modules/@next/swc-linux-arm64-musl):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-linux-arm64-musl@14.2.4: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-win32-arm64-msvc@14.2.4 (node_modules/next/node_modules/@next/swc-win32-arm64-msvc):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-win32-arm64-msvc@14.2.4: wanted {"os":"win32","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-win32-ia32-msvc@14.2.4 (node_modules/next/node_modules/@next/swc-win32-ia32-msvc):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-win32-ia32-msvc@14.2.4: wanted {"os":"win32","arch":"ia32"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/swc-win32-x64-msvc@14.2.4 (node_modules/next/node_modules/@next/swc-win32-x64-msvc):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/swc-win32-x64-msvc@14.2.4: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-darwin-arm64@0.33.4 (node_modules/sharp/node_modules/@img/sharp-darwin-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-darwin-arm64@0.33.4: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-darwin-x64@0.33.4 (node_modules/sharp/node_modules/@img/sharp-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-darwin-x64@0.33.4: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-darwin-x64@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-darwin-x64@1.0.2: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-linux-arm@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-linux-arm):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-linux-arm@1.0.2: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-darwin-arm64@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-darwin-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-darwin-arm64@1.0.2: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-linux-arm64@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-linux-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-linux-arm64@1.0.2: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-linux-s390x@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-linux-s390x):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-linux-s390x@1.0.2: wanted {"os":"linux","arch":"s390x"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-libvips-linuxmusl-arm64@1.0.2 (node_modules/sharp/node_modules/@img/sharp-libvips-linuxmusl-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-libvips-linuxmusl-arm64@1.0.2: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-linux-arm@0.33.4 (node_modules/sharp/node_modules/@img/sharp-linux-arm):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-linux-arm@0.33.4: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-linux-arm64@0.33.4 (node_modules/sharp/node_modules/@img/sharp-linux-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-linux-arm64@0.33.4: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-linux-s390x@0.33.4 (node_modules/sharp/node_modules/@img/sharp-linux-s390x):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-linux-s390x@0.33.4: wanted {"os":"linux","arch":"s390x"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-linuxmusl-arm64@0.33.4 (node_modules/sharp/node_modules/@img/sharp-linuxmusl-arm64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-linuxmusl-arm64@0.33.4: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-wasm32@0.33.4 (node_modules/sharp/node_modules/@img/sharp-wasm32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-wasm32@0.33.4: wanted {"os":"any","arch":"wasm32"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-win32-ia32@0.33.4 (node_modules/sharp/node_modules/@img/sharp-win32-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-win32-ia32@0.33.4: wanted {"os":"win32","arch":"ia32"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @img/sharp-win32-x64@0.33.4 (node_modules/sharp/node_modules/@img/sharp-win32-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @img/sharp-win32-x64@0.33.4: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})

npm ERR! Invalid dependency type requested: alias

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-06-26T16_28_18_480Z-debug.log

3921 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
3922 verbose stack Error: Invalid dependency type requested: alias
3922 verbose stack     at getFetcher (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:68:15)
3922 verbose stack     at manifest (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:15:19)
3922 verbose stack     at pinflight (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/pacote/manifest.js:24:12)
3922 verbose stack     at /server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
3922 verbose stack     at Promise._execute (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:303:9)
3922 verbose stack     at Promise._resolveFromExecutor (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
3922 verbose stack     at new Promise (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
3922 verbose stack     at _inflight (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
3922 verbose stack     at /server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
3922 verbose stack     at tryCatcher (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
3922 verbose stack     at Promise._settlePromiseFromHandler (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
3922 verbose stack     at Promise._settlePromise (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
3922 verbose stack     at Promise._settlePromiseCtx (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:606:10)
3922 verbose stack     at Async._drainQueue (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:138:12)
3922 verbose stack     at Async._drainQueues (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
3922 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (/server/node/node-v10.9.0-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
3923 verbose cwd /docker/dify-main/web
3924 verbose Linux 4.18.0-80.11.2.el8_0.x86_64
3925 verbose argv "/server/node/node-v10.9.0-linux-x64/bin/node" "/server/node/node-v10.9.0-linux-x64/bin/npm" "install"
3926 verbose node v10.9.0
3927 verbose npm  v6.2.0
3928 error Invalid dependency type requested: alias
3929 verbose exit [ 1, true ]
dosubot[bot] commented 3 months ago

Hello @ganggangtian! I'm here to assist you with any bugs, questions, or contributions you may have. I can help you solve bugs, answer questions, and even guide you to become a contributor. Let me know how I can assist you with the npm install error.

To resolve the "Invalid dependency type requested: alias" error and successfully install the dependencies for Dify version 0.6.11 on your Linux system, follow these steps:

  1. Ensure Node.js Version Compatibility: Make sure you are using Node.js version >=18.17.0 as specified in the engines field of the package.json.

  2. Update npm: Ensure you have the latest version of npm installed. You can update npm using the following command:

    npm install -g npm
  3. Clear npm Cache: Sometimes, clearing the npm cache can resolve dependency issues. Run the following command:

    npm cache clean --force
  4. Install Dependencies: Try installing the dependencies again using the following command:

    npm install

These steps should help resolve the issue [1].

To continue talking to Dosu, mention @dosu.

ganggangtian commented 3 months ago

@Dosu, npm install version is 20 now,and also error: (base) [root@iZuf6fksh2blifag87jb4pZ web]# npm install

dify-web@0.6.11 prepare cd ../ && node -e "if (process.env.NODE_ENV !== 'production'){process.exit(1)} " || husky install ./web/.husky

fatal: not a git repository (or any of the parent directories): .git husky - git command not found, skipping install

added 3 packages in 7s

361 packages are looking for funding run npm fund for details (base) [root@iZuf6fksh2blifag87jb4pZ web]# npm fund 11

dosubot[bot] commented 3 months ago

To resolve the issue where Husky is unable to find the .git directory when running npm install, you can modify the prepare script in the package.json file. The current prepare script is:

"prepare": "cd ../ && node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install ./web/.husky"

This script changes the directory to the parent directory and then checks if the NODE_ENV is not 'production'. If it is not 'production', it exits with a status of 1; otherwise, it attempts to install Husky hooks.

To ensure Husky can find the .git directory, you should modify the prepare script to:

"prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install"

This script will run the Husky installation command in the current directory, assuming the .git directory is in the root of your project.

Here is the updated package.json snippet:

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "cp -r .next/static .next/standalone/.next/static && cp -r public .next/standalone/public && cross-env PORT=$npm_config_port HOSTNAME=$npm_config_host node .next/standalone/server.js",
  "lint": "next lint",
  "fix": "next lint --fix",
  "eslint-fix": "eslint --fix",
  "prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install",
  "gen-icons": "node ./app/components/base/icons/script.js",
  "uglify-embed": "node ./bin/uglify-embed",
  "check-i18n": "node ./i18n/script.js"
}

This should resolve the issue with Husky not being able to find the .git directory [1].

To continue talking to Dosu, mention @dosu.

ganggangtian commented 3 months ago

@dosu, i modify the package.json,but still error: (base) [root@iZuf6fksh2blifag87jb4pZ web]# head -n 20 package.json { "name": "dify-web", "version": "0.6.11", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "cp -r .next/static .next/standalone/.next/static && cp -r public .next/standalone/public && cross-env PORT=$npm_config_port HOSTNAME=$npm_config_host node .next/standalone/server.js", "lint": "next lint", "fix": "next lint --fix", "eslint-fix": "eslint --fix", "prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install", "gen-icons": "node ./app/components/base/icons/script.js", "uglify-embed": "node ./bin/uglify-embed", "check-i18n": "node ./i18n/script.js" }, "dependencies": { "@babel/runtime": "^7.22.3", "@dagrejs/dagre": "^1.1.2", "@emoji-mart/data": "^1.1.2", (base) [root@iZuf6fksh2blifag87jb4pZ web]# npm install

dify-web@0.6.11 prepare node -e "if (process.env.NODE_ENV !== 'production'){process.exit(1)} " || husky install

fatal: not a git repository (or any of the parent directories): .git husky - git command not found, skipping install

up to date in 2s

361 packages are looking for funding run npm fund for details

dosubot[bot] commented 3 months ago

The error message indicates that the .git directory is not found, which is necessary for Husky to install its hooks. Here are a few steps to troubleshoot and resolve this issue:

  1. Ensure Git is Installed: Verify that Git is installed on your system and accessible from the command line. You can check this by running:

    git --version

    If Git is not installed, you can install it using your package manager. For example, on a Debian-based system, you can use:

    sudo apt-get install git
  2. Initialize a Git Repository: If your project directory is not already a Git repository, you need to initialize it. Navigate to the root of your project and run:

    git init
  3. Check the .git Directory: Ensure that the .git directory exists in the root of your project. If it does not, initializing the repository as mentioned above should create it.

  4. Verify the prepare Script: Ensure that the prepare script in your package.json is correctly modified as follows:

    "prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install"

After performing these steps, try running npm install again. This should resolve the issue with Husky not being able to find the .git directory.

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 months ago

Try to remove the node_modules folder and package-json.lock and run npm install again. Make sure node version is 20.x. This is a general frontend package manager issue, please google it before opening a issue, don't forget to use proper markdown syntax to format the code as well. :)

ganggangtian commented 3 months ago

@dosu,it is ok,sucess to build.tks~