首页 > 解决方案 > 下一个 js 在位置 0 处运行 dev 意外令牌 u 在 JSON 中

问题描述

我想学习 Next Js 并关注了 Traversy Media 的 Youtube Video Next.js Crash Course - Server Side React

我还遵循了Nextjs 官方文档中的 setps

我刚刚将以下代码放在 pages/index.js 文件中

export default function Home()
{
    return <h1>Welcome to my Website</h1>
}

在 Package.json 我放了下面的代码:

"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},

我在 cmd 下运行以运行下一个应用程序

npm run dev

当我打开我的 Chrome 浏览器时,我看到没有呈现任何内容,并且在控制台中我遇到了以下错误。

VM117:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at eval (platform.js?2a2e:14) at Object../node_modules/ally.js/util/platform.js (main.js?ts=1592604315070:1786) at __webpack_require__ (webpack.js?ts=1592604315070:863) at fn (webpack.js?ts=1592604315070:151) at eval (detect-focus.js?93d2:19) at Object../node_modules/ally.js/supports/detect-focus.js (main.js?ts=1592604315070:1102) at __webpack_require__ (webpack.js?ts=1592604315070:863) at fn (webpack.js?ts=1592604315070:151) at eval (supports.js?750b:21)

我需要做任何其他设置来启动下一个应用程序吗?

标签: javascriptnpmnext.js

解决方案


我建议这"scripts":...应该放在 pre-filled 中的特定位置Package.json,而不是替换整个文件


推荐阅读