Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

fix-cwd

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fix-cwd

Fix the current working directory by resolving it to its OS-canonical path before running a command.

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
7
133.33%
Maintainers
1
Weekly downloads
 
Created
Source

fix-cwd

Fix the current working directory by resolving it to its OS-canonical path before running a command.

Some tools incorrectly set process.cwd() to a path with a lowercase drive letter on Windows (e.g. c:\project instead of C:\Project). This causes issues with require.resolve, import.meta.url, import.meta.dirname, and other path-sensitive APIs. fix-cwd resolves the cwd to its true path using fs.realpathSync.native() before spawning your command.

Install

npm install --save-dev fix-cwd

Usage

Prefix your scripts with fix-cwd:

{
  "scripts": {
    "dev": "fix-cwd vitest",
    "build": "fix-cwd vite build"
  }
}

How it works

  • Calls fs.realpathSync.native(".") to get the OS-canonical path of the current directory
  • Spawns your command with the corrected cwd
  • Forwards signals and exit codes transparently

On Windows, realpathSync.native calls GetFinalPathNameByHandle, which returns the true-cased path (uppercase drive letter, correct directory casing). On Linux/macOS, it's effectively a no-op.

License

MIT

Keywords

cwd

FAQs

Package last updated on 15 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts