为什么`npm run dev`不能在新的`npx create-next-app`上工作?

scyqe7ek  于 2023-04-20  发布在  其他
关注(0)|答案(1)|浏览(194)

我刚刚用npx create-next-app创建了一个新的Next应用程序。它似乎已经成功运行:

$ 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
...
+ typescript@5.0.4
+ next@13.3.0
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.

那么I cd sightsee; npm run dev

name@MacBook-Pro-3: ~/sideProjects/sightsee main!
$ npm run dev                                                                     [9:30:12]

> sightsee@0.1.0 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]

> sightsee@0.1.0 build /Users/name/path/project next build

uncaughtException Error: Cannot find module 'node:buffer'
...
...
FAIL

我刚刚创建了这个项目,为什么没有任何工作?
我尝试重新安装节点模块,重新安装npx,都没有效果。
为什么npx create-next-app创建的应用程序无法运行?

tuwxkamq

tuwxkamq1#

解决了这个问题-问题是我之前在另一个目录中工作,需要旧版本的node(6.14.8!),所以在我的sideProjects文件夹中,我运行echo "18.5.0" > .nvmrc,然后运行nvm use,以使用最新版本。然后我删除了旧的应用程序,并再次运行相同的东西,现在一切正常!
:D希望这对某人有帮助

相关问题