Yarn 和 NextJS 的 Windows 驱动器盘符中的大小写无效
Invalid casing in Windows drive letter with Yarn and NextJS
我今天在 Windows 机器上使用 Yarn 和 NextJS 设置了一个新项目。启动时,我收到一条错误消息,指出外壳对于我的项目目录“无效”。具体来说,我看到以下错误:
Invalid casing detected for project dir, received c:\super-amazing-project actual path C:\super-amazing-project
There are multiple modules with names that only differ in casing.
关键是错误消息中的两个路径完全相同除了驱动器号。
我该如何解决这个问题?
版本
- Yarn 版本 1.22.17
- NextJS 版本 12.1.5
控制台输出
c:\super-amazing-project>yarn dev
yarn run v1.22.17
$ next dev
warn - Invalid casing detected for project dir, received c:\super-amazing-project actual path C:\super-amazing-project, see more info here https://nextjs.org/docs/messages/invalid-project-dir-casing
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
./node_modules/react/cjs/react.development.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\super-amazing-project\node_modules\react\cjs\react.development.js
Used by 2 module(s), i. e.
C:\super-amazing-project\node_modules\react\index.js
* c:\super-amazing-project\node_modules\react\cjs\react.development.js
Used by 2 module(s), i. e.
c:\super-amazing-project\node_modules\react\index.js
package.json
{
"name": "super-amazing-project",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@chakra-ui/react": "^1.8.8",
"@emotion/react": "11",
"@emotion/styled": "11",
"framer-motion": "6",
"next": "12.1.5",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-icons": "^4.3.1"
},
"devDependencies": {
"@types/node": "17.0.25",
"@types/react": "18.0.6",
"@types/react-dom": "18.0.2",
"eslint": "8.13.0",
"eslint-config-next": "12.1.5",
"typescript": "4.6.3"
}
}
您可能在命令终端中使用类似cd c:\super-amazing-project
的命令更改了Windows上的驱动器盘符的大小写,然后使用cd c:\super-amazing-project
设置项目小写 Windows 驱动器号。这会导致奇怪的问题,例如您遇到的问题。
解决方法 1. 改变盘符大小写再试yarn dev
您可以使用 cd
命令更改 Windows 上驱动器号的 大小写
C:\super-amazing-project>cd c:\
c:\>cd super-amazing-project
c:\super-amazing-project> yarn dev
解决方案 2. 使用默认的大写盘符重新设置项目
在 Windows 上使用 non-default 小写驱动器号进行安装可能会使您的新项目处于错误状态。如果这个项目是新项目,可能更容易再次 运行 npx create-next-app
并复制您的项目文件。
我今天在 Windows 机器上使用 Yarn 和 NextJS 设置了一个新项目。启动时,我收到一条错误消息,指出外壳对于我的项目目录“无效”。具体来说,我看到以下错误:
Invalid casing detected for project dir, received c:\super-amazing-project actual path C:\super-amazing-project
There are multiple modules with names that only differ in casing.
关键是错误消息中的两个路径完全相同除了驱动器号。
我该如何解决这个问题?
版本
- Yarn 版本 1.22.17
- NextJS 版本 12.1.5
控制台输出
c:\super-amazing-project>yarn dev
yarn run v1.22.17
$ next dev
warn - Invalid casing detected for project dir, received c:\super-amazing-project actual path C:\super-amazing-project, see more info here https://nextjs.org/docs/messages/invalid-project-dir-casing
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
./node_modules/react/cjs/react.development.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\super-amazing-project\node_modules\react\cjs\react.development.js
Used by 2 module(s), i. e.
C:\super-amazing-project\node_modules\react\index.js
* c:\super-amazing-project\node_modules\react\cjs\react.development.js
Used by 2 module(s), i. e.
c:\super-amazing-project\node_modules\react\index.js
package.json
{
"name": "super-amazing-project",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@chakra-ui/react": "^1.8.8",
"@emotion/react": "11",
"@emotion/styled": "11",
"framer-motion": "6",
"next": "12.1.5",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-icons": "^4.3.1"
},
"devDependencies": {
"@types/node": "17.0.25",
"@types/react": "18.0.6",
"@types/react-dom": "18.0.2",
"eslint": "8.13.0",
"eslint-config-next": "12.1.5",
"typescript": "4.6.3"
}
}
您可能在命令终端中使用类似cd c:\super-amazing-project
的命令更改了Windows上的驱动器盘符的大小写,然后使用cd c:\super-amazing-project
设置项目小写 Windows 驱动器号。这会导致奇怪的问题,例如您遇到的问题。
解决方法 1. 改变盘符大小写再试yarn dev
您可以使用 cd
命令更改 Windows 上驱动器号的 大小写
C:\super-amazing-project>cd c:\
c:\>cd super-amazing-project
c:\super-amazing-project> yarn dev
解决方案 2. 使用默认的大写盘符重新设置项目
在 Windows 上使用 non-default 小写驱动器号进行安装可能会使您的新项目处于错误状态。如果这个项目是新项目,可能更容易再次 运行 npx create-next-app
并复制您的项目文件。