我刚刚创建了一个新的 Next 应用程序npx create-next-app
。看起来已经成功运行了:
$ npx create-next-app [8:46:31]
npx: installed 1 in 8.826s
✔ What is your project named? … sightsee
✔ Would you like to use TypeScript with this project? Yes
✔ Would you like to use ESLint with this project? Yes
✔ Would you like to use Tailwind CSS with this project? Yes
✔ Would you like to use `src/` directory with this project? Yes
✔ Would you like to use experimental `app/` directory with this project? No
✔ What import alias would you like configured? … @/*
Creating a new Next.js app in /Users/name/sideProjects/sightsee.
Using npm.
Initializing project with template: default-tw
...
... irrelevant output
...
+ [email protected] /cdn-cgi/l/email-protection
+ [email protected] /cdn-cgi/l/email-protection
added 329 packages from 271 contributors and audited 338 packages in 182.455s
116 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Success! Created sightsee at /Users/name/sideProjects/sightsee.
Then I cd sightsee; npm run dev
:
name@MacBook-Pro-3: ~/sideProjects/sightsee main!
$ npm run dev [9:30:12]
> [email protected] /cdn-cgi/l/email-protection dev /Users/name/sideProjects/sightsee
> next dev
name@MacBook-Pro-3:~/sideProjects/sightsee main!
通常它会说类似的话running on port localhost:3000
.
npm run build
$ npm run build [9:29:43]
> [email protected] /cdn-cgi/l/email-protection build /Users/name/path/project next build
uncaughtException Error: Cannot find module 'node:buffer'
...
...
FAIL
我刚刚创建了这个项目,为什么没有任何效果?
我尝试重新安装节点模块,重新安装npx,都没有效果。
Why is npx create-next-app
创建一个无法运行的应用程序?
检查当前使用的节点版本,如果是旧版本可能会出现此错误;
为了检查当前运行的版本
node -v
用于更新到新的 LTS 版本
nvm安装18
在运行 npm run dev 或 build 之前确保 nvm 使用新版本
nvm使用18
Then
npm 运行构建
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)