npm / npm/cli

[BUG] npm run fails on Windows when project folder is case sensitive

Open
#3,299 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug cmd:run-script platform:windows Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

When case sensitivity is enabled, all scripts, e.g. npm run build, will fail with the error:

'module_name' is not recognized as an internal or external command

Where module_name is the name of the the module called by the script, e.g. webpack or cross-env

Expected Behavior

npm run should run scripts as normal, unaffected by the case sensitivity setting of the project folder (or its subfolders).

Steps To Reproduce
  1. Open a command prompt or PowerShell window at the location of your project folder
  2. Delete node_modules if it already exists
  3. Make the project folder case sensitive using fsutil.exe file setCaseSensitiveInfo . enable
  4. Run npm i
  5. Try to run any script defined in your package.json file, e.g. npm run build
  6. The script fails with an error similar to 'module_name' is not recognized as an internal or external command

As an alternative to steps 1-4, you could also recursively apply case sensitivity to the content of your project folder using this PowerShell command:

(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable}
Environment
  • OS: Windows 10 Pro (Microsoft Windows NT 10.0.19042.0 x64)
  • Node: 14.17.0
  • npm: 7.14.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure on Windows 10 using a package.json script such as npm run build, after enabling case sensitivity with fsutil.exe or the provided PowerShell command. Start at the npm run entry point and trace how script modules such as webpack or cross-env are resolved; done means scripts run normally in a case-sensitive project folder.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.