安装 Gatsby.js 入门模板时出错



我想使用
gatsby.js使用 npm install 全局安装gatsby-cli制作 Web 应用程序。
但是每当我运行gatsby new gatsby-starter-forty https://github.com/codebushi/gatsby-starter-forty或任何其他启动器模板命令时。我总是在我的终端中出现以下错误

C:UsersSachin VermaDesktopgatsby>gatsby new gatsby-starter-forty https://github.com/codebushi/gatsby-starter-forty
info Creating new site from git: https://github.com/codebushi/gatsby-starter-forty.git
Cloning into 'gatsby-starter-forty'...
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (83/83), done.
Uremote: Total 88 (delta 7), reused 72 (delta 4), pack-reused 0
Unpacking objects: 100% (88/88), done.
[32msuccess[39m Created starter directory layout
[34minfo[39m Installing packages...
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm ERR! Unexpected end of JSON input while parsing near '...n"},"engines":{"node"'
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersSachin VermaAppDataRoamingnpm-cache_logs2020-05-10T15_43_11_180Z-debug.log
ERROR
Command failed with exit code 1: npm install

Error: Command failed with exit code 1: npm install
- error.js:56 makeError
[npm]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[npm]/[gatsby-cli]/[execa]/index.js:114:26
- task_queues.js:97 processTicksAndRejections
internal/process/task_queues.js:97:5

请提出一些解决方法。因为我是 Node 的新手.js并且无法完全理解错误

从您的控制台输出来看,我可以看到您使用的是Windows。您需要一些额外的设置才能获得工作环境。

看看 Windows 文档上的官方 Gatsby。

简而言之,Gatsby建议安装windows-build-tools软件包以在Windows上运行:

在 Windows 上设置生成环境的推荐方法是通过运行npm install --global windows-build-tools --vs2015来安装windows-build-tools

如果这对您不起作用,可以在 Windows 文档上的官方 Gatsby 文档中提供更多信息(包括故障排除(。

或者,如果您使用的是Windows 10,一个好的解决方案是在Windows子系统Linux(WSL(中使用Gatsby。若要进行设置,请按照 WSL Linux 文档中的说明进行操作。

最新更新