Why can't React project name contain capital letters?

≡放荡痞女 提交于 2021-02-08 16:38:08

问题


I got the following message while trying to create a new project "newRecipeApp" in React.

npx: installed 91 in 29.359s
Could not create a project called "newRecipeApp" because of npm naming restrictions:
  *  name can no longer contain capital letters

What is the reason for this? Why is there a naming restriction in npm for capital letters?


回答1:


you can read this https://github.com/facebook/create-react-app/issues/2165 NPM packages are not allowed upper case characters in their name, seemingly because unix filesystems are case-sensitive, which creates "a recipe for confusion and nonportable software".

This makes perfect sense in the context of libraries intended as portable software; however, not so much when speaking about end-of-the-line applications, especially those developed in a case-insensitive environment like Windows.

PR1652 introduced project name validation using validate-npm-package-name, assumedly to avoid issues with output displaying spaces in names.

Should "React applications", being a different (eg: less focused on "portability") category of software, have these same restrictions?

For example, I am not trying to make an npm package / library. I am trying to use create-react-app to generate an application, and I need to follow application naming conventions in my company which requires the use of capital letters in the application name.




回答2:


This is likely to reconcile naming issues between linux and OSX. Linux differentiates between dirs/files with the same names, but with capital letters and OSX does not. So imagine someone created a project in linux called WebApp and another called webapp. If they tried to download both to an OSX platform, one of these projects would be overwritten. To fix this, NPX devs probably decided to just force all directory names to lowercase so if a linux user created webapp then tried to create or download WebApp, there would be a protection against that for mac users that need to download both projects.




回答3:


It's mostly because NPM doesn't allow capital letters. So to ensure compatibility with the naming scheme of NPM they might have done it.



来源:https://stackoverflow.com/questions/59159553/why-cant-react-project-name-contain-capital-letters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!