Reddspark
Reddspark

Reputation: 7577

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

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

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!

Upvotes: 2

Views: 10196

Answers (5)

Don Milligan
Don Milligan

Reputation: 21

In Windows 11, the issue for me was that I was running pnpm from a repo where there was a space in the directory listing.

This is not compatible with Unix style directory references without special characters to escape spaces, and maybe it's a blanket statement, but PNPM is created for use in Linux primarily.

Running our code from Google Drive in Windows leaves us with a directory named ("My Drive") which was the cause in my case. Try running the repo from a a directory where none of the parents have a space.

Upvotes: 1

Keios Starqua
Keios Starqua

Reputation: 39

You should install pnpm and set its store path to the same partition. And it should be your main partition (the partition you install Windows)

You can check the store path of pnpm with:

pnpm store path

To change store path of pnpm. Run the command below:

pnpm config set store-dir C:\Users\%YOUR_USERNAME%\AppData\Local\pnpm\store\v3

Change %YOUR_USERNAME% with the text in your situation.

In my case, the C:\ is the location I installed Windows.

The store path default is: C:\Users\%YOUR_USERNAME%\AppData\Local\pnpm\store\v3

Read more at pnpm docs

Upvotes: 0

Abhishek Pankar
Abhishek Pankar

Reputation: 743

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

The issue is discussed here

Upvotes: 0

Zoltan Kochan
Zoltan Kochan

Reputation: 7696

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.

Upvotes: 1

Reddspark
Reddspark

Reputation: 7577

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.

Upvotes: -1

Related Questions