PNPM Install - Error: ENOENT: no such file or directory

2.4k Views Asked by At

I was following an online tutorial and it suggestd using PMPM as its better than NPM.

As I am on Windows I ran:

iwr https://get.pnpm.io/install.ps1 -useb | iex

in my root folder (D:/) but I get the error:

node:fs:2552
      handleErrorFromBinding(ctx);
      ^

Error: ENOENT: no such file or directory, lstat 'D:\projects\aston\nextjs\my_username'
    at Object.realpathSync (node:fs:2552:7)
    at Object.realpathSync (pkg/prelude/bootstrap.js:1361:36)
    at ../node_modules/.pnpm/[email protected]/node_modules/temp-dir/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../node_modules/.pnpm/[email protected]/node_modules/tempy/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../env/node.fetcher/lib/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../env/plugin-commands-env/lib/node.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs) {
  errno: -4058,
  syscall: 'lstat',
  code: 'ENOENT',
  path: 'D:\\my_username'
}
  1. Why am I getting this error? / How do I resolve?
  2. Why does it matter which folder I am in when I run this command? Shouldn't it be defaulting to C:\Users\my_username - or is the fact I'm doing this from the d drive confusing it? (I also installed node.js on the d dive due to space constraints on my main c drive)
  3. Also my windows username folder is c:\users\username_with_last_letter_chopped_off
  • but this install is asking for D:\\full_username. Therefore running in the install command from my c:\\users directory does not solve things either.

Ok so then I tried running npm install instead which ran successfully.. 3. Does it matter which folder I am in when run this?

Then I created my Next.JS app using npx create-next-app@latest and Cd'd into the folder

Within this folder I then ran pnpm install because that's why i saw in the tutorial. This then gave me the error:

node:fs:2552
      handleErrorFromBinding(ctx);
      ^

Error: ENOENT: no such file or directory, lstat 'D:\projects\aston\nextjs\my_username'
    at Object.realpathSync (node:fs:2552:7)
    at Object.realpathSync (pkg/prelude/bootstrap.js:1361:36)
    at ../node_modules/.pnpm/[email protected]/node_modules/temp-dir/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../node_modules/.pnpm/[email protected]/node_modules/tempy/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../env/node.fetcher/lib/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../env/plugin-commands-env/lib/node.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs) {
  errno: -4058,
  syscall: 'lstat',
  code: 'ENOENT',
  path: 'D:\\projects\\aston\\nextjs\\my_username'
}
  1. As you see it is looking for: 'D:\projects\aston\nextjs\my_username'

Well I obvioulsly would not want my_username to be part of my app folder. So what folder shoud I be running it from.

  1. Finally I keep noticing a D:\\projects\\my_username\\AppData\\Local folder being created at various times. Why is this appearing in my projects folder. Shouldn't it be defaulting to using my actual Windows username folder? Or is it because I'm on the D directory instead of the C drive and it's getting confused?

So yeah as you can see I'm confused about a lot of things!

Edit: Ok I created this folder:

C:\Users\full_username\AppData\Local

and now iwr https://get.pnpm.io/install.ps1 -useb | iex seems to have worked. But now if I go into my project folder and type pnpm just to see if it's detected it gives the error:

node:fs:2552
      handleErrorFromBinding(ctx);
      ^

Error: ENOENT: no such file or directory, lstat 'D:\projects\aston\nextjs\my_username'
  ...
  errno: -4058,
  syscall: 'lstat',
  code: 'ENOENT',
  path: 'D:\\projects\\aston\\nextjs\\my_username'
}

But I don't want my username to be in my project folder!

3

There are 3 best solutions below

1
Reddspark On

Ok after reading through: https://pnpm.io/faq

I concluded that PNPM is just buggy on windows,esp. when you have different volumes like I do. Will just give up on it and stick to npm.

0
Zoltan Kochan On

Looks like an issue with the standalone installation script for Windows. Feel free to create an issue about it in the pnpm repository.

There are many other ways to install pnpm, so I recommend to remove the broken pnpm. Then you can install it using one of the ways described on the installation page. The easiest way is using corepack. Node.js is shipped with pnpm, so you can just run corepack enable and pnpm will be available in your terminal.

0
Abhishek Pankar On

Try deleting node_modules and pnpm-lock.yaml. Then run pnpm store prune and pnpm i

The issue is discussed here