如何解决在运行新创建的Next.js应用时出现的警告?

huangapple go评论65阅读模式
英文:

How to resolve warnings while running newly created Next.js app?

问题

我使用 npx create-next-app ./ 创建了一个新的 Next.js 应用程序。
我没有触碰任何代码,甚至没有在编辑器中打开它。

在使用 npm run dev 运行此应用程序时,我得到了这些非常长的警告信息。

$ npm run dev

> test@0.1.0 dev
> next dev

- 已经启动服务器,监听 0.0.0.0:3000,访问地址: http://localhost:3000
- 编译客户端和服务器成功,用时 1605 毫秒(共 20 个模块)
- 等待编译...
- 编译客户端和服务器成功,用时 593 毫秒(共 20 个模块)
- 等待编译 /page(客户端和服务器)...
- 警告 ./node_modules/next/dist/client/add-base-path.js
存在多个模块具有仅大小写不同的名称。
在具有其他大小写语义的文件系统上编译时,这可能导致意外行为。
请使用相同的大小写。比较这些模块标识符:
* javascript/auto|C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\compiled\@next\react-refresh-utils\dist\loader.js!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\webpack\loaders\next-flight-client-module-loader.js!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\webpack\loaders\next-swc-loader.js??ruleSet[1].rules[6].oneOf[4].use[2]!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\client\add-base-path.js|app-client
3 个模块使用,例如
    javascript/auto|C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\compiled\@next\react-refresh-utils\dist\loader.js!C:\Users.Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\................. 

尽管出现警告信息,页面仍然正常加载。

英文:

I created a new next.js app using npx create-next-app ./
I didn’t touch any code or even open it in an editor.

While running this app using npm run dev, I get these really long warnings.

$ npm run dev

> test@0.1.0 dev
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- event compiled client and server successfully in 1605 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 593 ms (20 modules)
- wait compiling /page (client and server)...
- warn ./node_modules/next/dist/client/add-base-path.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:
* javascript/auto|C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\compiled\@next\react-refresh-utils\dist\loader.js!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\webpack\loaders\next-flight-client-module-loader.js!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\webpack\loaders\next-swc-loader.js??ruleSet[1].rules[6].oneOf[4].use[2]!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\client\add-base-path.js|app-client
    Used by 3 module(s), i. e.
    javascript/auto|C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\compiled\@next\react-refresh-utils\dist\loader.js!C:\Users\Admin\Desktop\Desktop\WD\NEXTjs\test\test\node_modules\next\dist\build\.................

The page loads though.

答案1

得分: 0

只需删除./然后运行命令。

npx create-next-app@latest

之后,当命令要求输入项目名称时,只需输入.并按回车键。

英文:

I think you just need to remove ./ and then run the command.

npx create-next-app@latest

After, when command ask for project name just write . and hit enter.

答案2

得分: 0

我找到了问题。
Next.js不喜欢将应用程序放在Desktop/desktop/...文件夹中,所以它会抛出错误。我只是更改了文件夹名称,然后它就正常工作了。

英文:

I found the problem.
Next.js didn’t like having the app inside the Desktop/desktop/… folder, so it was throwing errors. I just changed the folder name and it worked.

huangapple
  • 本文由 发表于 2023年7月13日 22:42:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定