cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] Windows support appears to be missing config and definitions files which were present in earlier versions of NodeJS

Open natesire opened this issue 7 months ago • 15 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

This issue exists in the latest npm version

  • [x] I am using the latest npm

Current Behavior

Missing files for Windows support.

Expected Behavior

I cannot find vital files which Windows needs to run npm

It looks like @npmcli/config/lib/definitions has either been moved in recent versions of Node or not included.

And because Windows needs it, npm will not run.

const Config = require('@npmcli/config')

Steps To Reproduce

  1. Windows
  2. Run 'npm' on the command line
  3. Missing @npmcli/config

Environment

  • npm: 10.9.2 and the Github latest code
  • Node.js: 22.14
  • OS Name: Windows 11
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here

npm will not run.

PS C:\Users\nates\github\cli> npm
node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '@npmcli/config'
Require stack:

The way to prevent these types of errors from getting into the "wild" is to setup a break-box on the infrastructure pipeline to test the nightly against various platforms: Linux, Windows, iOs. Instead of relying on developers to test the releases. I will have to try rolling back the npm version to a previous version but since the node version is so tightly coupled to the npm version, not sure it will work. I'll have to rollback my Node version too.

natesire avatar May 15 '25 13:05 natesire

Ok, see this is the other problem. Because we use npm to manage itself, it's own installation and versioning. When NPM breaks, we cannot fix anything by rolling back. Just rolled back my Node version with NVM. But NVM didn't rollback to an older NPM version as well. And because the latest NPM is broken, it means I have to manually rip it out of my system.

natesire avatar May 15 '25 13:05 natesire

@natesire I believe it's related to installation that you are getting the error, Checkout if these guides help you fix the broken installation of npm https://docs.npmjs.com/cli/v11/using-npm/removal https://github.com/npm/cli?tab=readme-ov-file#direct-download

milaninfy avatar May 15 '25 14:05 milaninfy

@milaninfy I will take a look at your install doc recommendations.

But it's NVM which does the install.

It looks like

@npmcli/config/lib

was deleted in Node 19. Then it was put back but moved under /workspaces in Node 20 and beyond.

So unless that @npmcli file scope is looking in workspaces, that's why it's not finding the files it needs to run on Windows.

I will test it by copying the files back into the folder to see if it returns a new error. Give me a minute.

natesire avatar May 15 '25 15:05 natesire

Yes, this is the problem. It's looking for the config files under workspaces folder.

When I fix the very first require, it works. But there's many more of them. The require statements need fixed to look in workspaces for all of those config files which setup the env properly for Windows to run.

natesire avatar May 15 '25 15:05 natesire

const Config = require('../workspaces/config') passes

but this doesn't const Config = require('@npmcli/config')

I am searching for that file scope @npmcli. Wherever it's set, needs tweaked.

natesire avatar May 15 '25 15:05 natesire

The @ is a NodeJS featured called a scoped package. The directory must remain with @npmcli in it's name.

So that config package will need moved back to the original location instead of under /workspaces.

Workspaces keeps making me think of VSCode workspaces.

natesire avatar May 15 '25 15:05 natesire

If any company's are reading this, and struggling to get their legacy Node apps upgraded.

I need some companies to pay me an annual fee to setup a break-box to test the nightly build against dozens of operating systems: Windows, Flavors of Linux and iOS. I have a workstation in my home to set it up and virtualize it.

It looks like Windows support for Node/NPM has been broken since Node 19. Which means no Azure Serverless and other Windows based stacks.

natesire avatar May 15 '25 15:05 natesire

@natesire I still think it might be related to installation of node and npm through nvm and not the code issue of npm. Can you try this if not already tried ? nvm uninstall YOUR_NODE_VERSION and then nvm install YOUR_NODE_VERSION

or you can try official channel for downloading node https://nodejs.org/en/download

milaninfy avatar May 15 '25 16:05 milaninfy

Sure, I will try. But I am 99% sure the config files for Windows are missing. And they need to be put back. Because those files do all kinds of presetup to make Node work on Windows.

I just swapped between Node 16, 17, 18, 19, 20 ,22, 23, 24. By the way the Node 23 exe is also broken. But I don't think it's LTS.

So Windows support for Node/NPM has been broken since Node 19.

Also, Node 18 had originally broke on Windows because of an earlier filesystem difference between Linux and Windows.

The root of the problem is: Node isn't being actively maintained on Windows systems. Because if it were, the dev would quickly see NPM is failing. The windows developers would see the npm doesn't even run on Node 19 and 23.

There are lots of squirrely problems with Windows filesystem. For example, Windows has a difficult time with extra long directory filename paths.

The repo needs a virtualized break-box built into the release pipeline. CI/CD.

natesire avatar May 15 '25 16:05 natesire

On a side note not related to the Node fix, I was going to just hop back onto Ubuntu to do some dev work for Node and work around this problem. Even though Windows still needs fixed. The Ubuntu team broke the network manager IP DNS. etc/resolv.conf, so I couldn't even get on the web to finish installing Ubuntu. I am taking a look at that next.

So it's happening a lot. There's just a lot of things breaking the last few years since the tech crash. A lot of free work needed done for companies. I am glad Github added the donation button. Devs are stressed out.

I am building a book publishing platform and need Node/React/React Native. But I also am working with WASM, C++ for Web Dev and Phone Dev. Cross platform. Desktop too.

natesire avatar May 15 '25 16:05 natesire

@natesire I see from the report that you are on C:\Users\nates\github\cli By any chance are you building or running npm from checking out npm git repository ?, ? if so then you might need to do npm install first before using it from source code.

milaninfy avatar May 15 '25 16:05 milaninfy

Well, see that's the chicken and egg problem. I couldn't even get npm to run on the command line to fix anything. That's the weakness with npm maintaining itself. I had no choice but to manually patch the code just to get npm to run.

natesire avatar May 15 '25 16:05 natesire

I am receiving a new error now with other version not related to this problem. There's problems either with the Node exe or npm calling the node exe. Exe access and exe encoding errors. Not sure. None of the NPM versions appear stable on Windows since at least Node v16

I had to abandon doing any new dev work for Node on Windows around Node v16. But there's a lot of enterprise companies out there who use Azure and will need support for this. Especially serverless and event streaming architecture.

I use Node for enterprise ETL and Serverless. Billions of records per hour. Also Disney. Massive scale on Node. For all the parks, hotels, cruise ships and Disney +. 20,000/s. So this is a very important problem to get fixed up and keep solved. Amazon is also relying on this.

I do love Node JS and NPM. So I don't mind helping. I will just put a workstation on it. And setup a virtualized cross OS break box. Then send you reports on when things break on the daily build.

natesire avatar May 15 '25 16:05 natesire

Hi @milaninfy, I followed you. Can you add some contact info to your Github profile so I can tweet you or something, instead of clogging up the ticket with my personal ramblings. I will proofread and edit this ticket to make sure it makes sense for others to read it.

natesire avatar May 15 '25 16:05 natesire

I spun up a Ubuntu box and NVM (node version manager) installed Node 24.0.2 with NPM 11.3.0 without any problem. I DON'T think it's NVM putting files in the wrong place.

I believe the NPM code is looking for the Windows env config setup files in the wrong place using that @npmcli file scope. It's only a problem on Windows because it needs those specific files to setup the Windows environment.

@npmcli and the config path. The other requires are failing too. The definitions file and so on.

I will submit a pull request once I track down a code fix. I moved the Windows config env files back to where they were in previous versions of Node, which fixed the problem on Windows. It's a file path dependency change between NPM and Node.

natesire avatar May 17 '25 16:05 natesire

@natesire I have been out recently. I see that your issue is fixed. In my multiple iteration of reproducing this issue on windows I was unable to do so, every time I was able to get npm to work with fresh installation in windows through node install as well as nvm install.

Closing this issue, but at any time you are managed to reproduce this issue at will on fresh install of windows please post those reproduction steps either on new issue or here and I'll reopen.

milaninfy avatar Jul 07 '25 17:07 milaninfy