coreybutler/nvm-windows

libnpmfund - npm ERR! Unexpected token '.'

Maxim-Mazurok opened this issue ยท 14 comments

Issue:
Can't use npm i with node 17.4.0 - 17.7.0

How To Reproduce:

  1. nvm install 17.4.0
  2. nvm use 17.4.0
  3. npm i
  4. See error

Expected Behavior:

No error (I guess it looks like failed symlink?)

This is C:\Users\maxim\AppData\Roaming\nvm\v17.4.0\node_modules\npm\node_modules\libnpmfund file contents:

../workspaces/libnpmfund

Desktop:

  • OS: Windows 11, Dev mode on
28 verbose stack C:\Users\maxim\AppData\Roaming\nvm\v17.7.0\node_modules\npm\node_modules\libnpmfund:1
28 verbose stack ../workspaces/libnpmfund
28 verbose stack ^
28 verbose stack
28 verbose stack SyntaxError: Unexpected token '.'
28 verbose stack     at Object.compileFunction (node:vm:352:18)
28 verbose stack     at wrapSafe (node:internal/modules/cjs/loader:1027:15)
28 verbose stack     at Module._compile (node:internal/modules/cjs/loader:1063:27)
28 verbose stack     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
28 verbose stack     at Module.load (node:internal/modules/cjs/loader:975:32)
28 verbose stack     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
28 verbose stack     at Module.require (node:internal/modules/cjs/loader:999:19)
28 verbose stack     at require (node:internal/modules/cjs/helpers:102:18)
28 verbose stack     at Object.<anonymous> (C:\Users\maxim\AppData\Roaming\nvm\v17.7.0\node_modules\npm\lib\utils\reify-output.js:16:38)
28 verbose stack     at Module._compile (node:internal/modules/cjs/loader:1099:14)

I cannot recreate. Can you provide a reproducible example?

image

I forgot to mention that I was trying to use 1.1.7 because of #767

npm i anything should produce the same error. All files in C:\Users\maxim\AppData\Roaming\nvm\v17.7.0\node_modules\npm\node_modules\lib* look like broken symlinks (one line, contents, similar to ../workspaces/libnpmfund

Tried on 1.1.9 in shell ran as admin, it works, and C:\Users\maxim\AppData\Roaming\nvm\v17.4.0\node_modules\npm\node_modules\libnpmfund seems like a regular folder, VS Code doesn't show it as a symlink or anything.

But running everything as admin isn't an option, so I have to use 1.1.7, which doesn't work with node version that I need for one of my projects, so I'm back to nvs, which is unfortunate.

I have a monorepo with a bunch of small projects, and all of them have different engines requirements specified in package.json, so I'm working on a script to install deps and run tests for all of them in parallel. It works pretty well on mac with a traditional nvm, but on windows with nvs it chokes as it attempts to read/write the same files when switching between node versions... So I wanted to give nvm4w a try

v1.1.7 and v1.1.9 both require administrative privileges, because Windows requires administrative privileges (or comparable permissions) to create symlinks. The difference is NVM4W 1.1.9 attempts to auto-suppress the UAC prompts. Suppression was a highly requested featured, but many users prefer it. I do not have time to support both approaches with this project, but it is something being addressed in rt (Runtime), the successor project I'm working on.

Thank you for sharing your use case. While I don't think there is anything that can immediately solve your particular situation, it is the type of situation that is on my radar (and being worked on).

Same problem here. The lib libnpmfund broke all the versions from Node for me from 16.16 up. I had to rollback all the way to 16.13.

I can't even update npm, no npm install or npm publish works.

same problem here

@italodeandra I finally fixed it. I download the nvm latest version and then use that to install v17.x.x. now the project can run npm install.

Same issue (OS: Windows 10):

22 verbose argv "install" "--global" "create-react-app"
23 timing npm:load:setTitle Completed in 3ms
24 timing config:load:flatten Completed in 15ms
25 timing npm:load:display Completed in 19ms
26 verbose logfile logs-max:10 dir:C:\Users\*\AppData\Local\npm-cache\_logs
27 verbose logfile C:\Users\*\AppData\Local\npm-cache\_logs\2022-11-10T12_59_41_140Z-debug-0.log
28 timing npm:load:logFile Completed in 25ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 1ms
31 timing npm:load Completed in 101ms
32 verbose stack C:\Users\*\AppData\Roaming\nvm\v18.12.1\node_modules\npm\node_modules\libnpmfund:1
32 verbose stack ../workspaces/libnpmfund
32 verbose stack ^
32 verbose stack
32 verbose stack SyntaxError: Unexpected token '.'

Reference to #npm/cli/issues/5662
I totally removed nvm 1.1.7 and installed 1.1.10, then reinstalled nodejs 18.12.1.
After that I tried to run command npm i -g create-react-app, and nothing went wrong.

Was running into the same issue with 16.18.0; installed 16.13.2 to resolve the issue.

I was getting these issues with nvm-windows, the fix for me was to

  1. open an administrator console
  2. run nvm uninstall {brokenNodeVersion}
  3. then reinstall that version with nvm install {brokenNodeVersion}

I was able to tell what versions of node were broken on my machine by looking at the libnpmfund folder under the C:\Users\{user}\AppData\Roaming\nvm\v{brokenNodeVersion}\node_modules\npm\node_modules\libnpmfund and there would be a bunch of broken files with no extension. The contents of the files would just be one line like ..\packageName
After re-installing with an admin console I see the broken files are gone and the folder looks like:
image

I know I'm a bit late to the party, but after googling this issue for 45 minutes this is the only thread that actually gave me any useful information, so I wanted to add my own two cents for how I got this to work.

removing and reinstalling the versions was not working for me even with admin console (probably missing something else) so I did this:

nvm install 16.14.0
nvm use 16.7.0 (or any previous version that worked)
cd ~/AppData/Roaming/nvm/v16.14.0/node_modules/npm
npm install

This will use the older version of npm, that works, to install the packages required by the newer one. Symlinks now work, I was able to switch back to node 16.14.0 and npm install.

Not sure if this will break something else further down the line but it has worked for me so far.

I have the same issue.
The OP mentioned something that others might have missed: failed symlink
I use symbolic links to force programs to install in my larger D: drive when there is no option to override the C:drive path manually.
I suspect there is a very niche group of people who go this far to keep things running smoothly with drive space on C:.

I removed my symbolic link gobbling up 2GB on my C: drive but it now works.

I had to uninstall nvm-windows and install latest into the same directory. That solved it for me.