【问题标题】:How to setup next.js?如何设置 next.js?
【发布时间】:2019-03-07 08:00:54
【问题描述】:

我只是按照官方网站的步骤:

https://nextjs.org/docs/

第一步。

npm install --save next react react-dom

步骤 2. 在 package.json 中添加脚本

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

第 3 步。 在项目中添加 ./pages/index.js:

export default () => <div>Welcome to next.js!</div>

然后我运行 npm run dev 并得到错误:

/Users/jh/Documents/worksapce/react/nextJs/test1/node_modules/webpackbar/dist/index.js:55
    const hasRunning = () => Object.values(sharedState).find(s => s.isRunning);
                                ^

TypeError: Object.values is not a function

我哪里做错了?

【问题讨论】:

  • 什么是sharedState,是对象还是数组?
  • 看到这个答案,我不认为这与 next.js 本身有关。看到这个答案:stackoverflow.com/questions/38748445/…
  • @ArrowHead 您好,感谢您的帮助。我发现我的节点版本太旧了,所以发生了错误。它在节点更新后工作。
  • 我很高兴你找到了答案。

标签: next.js


【解决方案1】:

这是由于您的节点版本。请升级您的节点版本。 Node >= 7.0.0 完全支持这个。

【讨论】:

    猜你喜欢
    • 2020-05-25
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 2020-02-02
    • 2022-06-12
    • 2022-12-12
    • 2019-07-06
    相关资源
    最近更新 更多