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

Update Node/npm and dependencies #8045

Merged
merged 14 commits into from
Aug 29, 2024
Merged

Update Node/npm and dependencies #8045

merged 14 commits into from
Aug 29, 2024

Conversation

ajlende
Copy link
Contributor

@ajlende ajlende commented Aug 28, 2024

Changes proposed in this Pull Request:

Update node version and dependencies that support the new version. The node version bump was needed to support URL.canParse() in #8039, but I figured updating the dependencies would be nice while we're at it.

Node version is now 20 to match core.

Most of the major version bumps were just dropping support for node 18 and 19, so no action was needed for many of them. There were a few exceptions.

  • husky@9 [changelog]: Required changes to .husky/pre-commit and prepare in package.json.
  • octokit@4 [changelog]: Dropped support for some features that we weren't using. Only used by create-a-theme-checklist.js, but it looked like no code changes were needed.
  • inquirer@10 [changelog]: Rewrite in TS, but was intended as a drop-in replacement. Used by some release workflows in theme-utils.mjs. Seemed like no code changes needed.
  • @wordpress/scripts@27 was intentionally left at v27 for WP <=6.5 support. See the v28 changelog for more info.
  • wp-prettier had a different installation method than was used for the current version, so I followed those instructions to reinstall the latest version. See the readme for more info.

Related issue(s):

@ajlende ajlende added the dependencies Pull requests that update a dependency file label Aug 28, 2024
@ajlende ajlende self-assigned this Aug 28, 2024
@vcanales
Copy link
Contributor

Running into node-gyp errors that the usual fixes didn't take care of:

❌ Rebuild dependencies
❌ Remove package-lock.json
❌ Clear dependency cache

Error message:

npm error Traceback (most recent call last):
npm error   File "/Users/vcanales/dev/themes/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
npm error     import gyp  # noqa: E402
npm error     ^^^^^^^^^^
npm error   File "/Users/vcanales/dev/themes/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
npm error     import gyp.input
npm error   File "/Users/vcanales/dev/themes/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
npm error     from distutils.version import StrictVersion
npm error ModuleNotFoundError: No module named 'distutils'
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
npm error gyp ERR! stack     at ChildProcess.onCpExit (/Users/vcanales/dev/themes/node_modules/node-gyp/lib/configure.js:259:16)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System Darwin 23.6.0
npm error gyp ERR! command "/Users/vcanales/.nvm/versions/node/v20.14.0/bin/node" "/Users/vcanales/dev/themes/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm error gyp ERR! cwd /Users/vcanales/dev/themes/node_modules/node-sass
npm error gyp ERR! node -v v20.14.0
npm error gyp ERR! node-gyp -v v8.4.1
npm error gyp ERR! not ok
npm error Build failed with error code: 1

Full log.

Unsure how I might help review this further; any suggestions?

@ajlende
Copy link
Contributor Author

ajlende commented Aug 28, 2024

Unsure how I might help review this further; any suggestions?

On the positive side, I was able to reproduce the issue. I cleaned the repo and ran npm ci and it started happening to me. Unfortunately, now it happens no matter the branch I switch to, even trunk. I'll report back if I figure anything out.

@ajlende
Copy link
Contributor Author

ajlende commented Aug 28, 2024

I'll report back if I figure anything out.

@vcanales I figured it out.

TL;DR Run brew install python-setuptools to fix it.

Some themes depend on node-sass. node-sass uses an old version of node-gyp (and won't update because node-sass is deprecated). The old version of node-gyp depends on distutils. However, Python doesn't ship with distutils anymore, so you need to install it separately.

On MacOS this is done with Homebrew: brew install python-setuptools.

On other systems it's done with PIP: pip install setuptools.

I'll see if I can update all the themes using node-sass to use the dart version instead which doesn't need node-gyp. That should clear things up for future devs.

Copy link
Member

@madhusudhand madhusudhand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the changes and it works! 🚢

@ajlende ajlende merged commit 563c806 into trunk Aug 29, 2024
1 check passed
@ajlende ajlende deleted the update/node-npm-version branch August 29, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants