volta icon indicating copy to clipboard operation
volta copied to clipboard

Project's gulp should run with Node.js 10 version

Open smallmain opened this issue 1 year ago • 6 comments

image

  • Since gulp needs to run with the old version of node, errors will not occur.
  • I fixed node version to 10 in this project.
  • gulp is installed globally and within this project.
  • After running gulp, the node version number used will be printed. You can see that if you do not use --node to explicitly specify the version number, the global version 20 will be used.

If gulp is installed in the project, the gulp version in the project should be used first, and the same is true for node.

smallmain avatar Nov 14 '24 12:11 smallmain

When using a globally installed package from volta which gulp should not be resolving to cocos-service-pack/src/node_modules/.bin/gulp, it should be found at ~/.volta/bin/gulp.

Some questions to figure out what is going on here:

  • Can you run ~/.volta/bin/gulp tttt?
  • How did you install gulp globally (what command did you run)?
  • Can you echo $PATH from cocos-service-pack/src/engine?
  • Can you run which -a gulp from cocos-service-pack/src/engine?
  • What are you using to add node_modules/.bin to your $PATH? Normally from within a repo, you cannot which foo and have it resolved from ./node_modules/.bin/, so it seems that something is adding ./node_modules/.bin to $PATH.

rwjblue avatar Nov 14 '24 13:11 rwjblue

@rwjblue

  • Can run normally, version is v22.11.0
  • I run npm i -g [email protected]
  • PATH: /Users/smallmain/.console-ninja/.bin:/Library/Frameworks/Python.framework/Versions/3.13/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/smallmain/.bun/bin:/Users/smallmain/.volta/bin
  • The result is: /Users/smallmain/.volta/bin/gulp
  • I didn't add it, the command I ran was volta which gulp and what it returned was /Users/smallmain/Documents/Work/cocos-service-pack-src/engine/node_modules/.bin/gulp

smallmain avatar Nov 14 '24 15:11 smallmain

If the correct behavior is to execute the globally installed gulp no matter what, how do I solve this problem when a project relies on older versions of gulp and node ?

smallmain avatar Nov 14 '24 15:11 smallmain

If the correct behavior is to execute the globally installed gulp no matter what

This is not the correct behavior. Take a look at this blog post that explains how Volta works RE: globals:

https://blog.volta.sh/2019/06/18/global-installs-done-right/

rwjblue avatar Nov 16 '24 15:11 rwjblue

If the correct behavior is to execute the globally installed gulp no matter what

This is not the correct behavior. Take a look at this blog post that explains how Volta works RE: globals:

https://blog.volta.sh/2019/06/18/global-installs-done-right/

Alright, so now it's indeed running correctly in the gulp project, but Node is not using the locked version of Node specified in the project.

smallmain avatar Nov 17 '24 07:11 smallmain

Probably the best thing to debug this further is to make a new temp / sandbox project and start porting things over until you can replicate the issue. That should help narrow things down for you a bunch.

rwjblue avatar Nov 17 '24 22:11 rwjblue