我无法启动gatsby入门项目。 new
命令过程在初始化期间中断,并导致错误和不可编译的项目。
这是命令:
> gatsby new gatsby-test
以下过程开始,在npm install
期间尝试安装锋利的软件包时失败。
info Creating new site from git:
Cloning into 'gatsby-test'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 2309 (delta 4), reused 10 (delta 4), pack-reused 2299
Receiving objects: 100% (2309/2309), 12.62 MiB | 7.98 MiB/s, done.
Resolving deltas: 100% (1487/1487), done.
success Created starter directory layout
info Installing packages...
> sharp@0.23.2 install /home/developer/projects/gatsby-test/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz
fs.js:114
throw err;
^
Error: EACCES: permission denied, copyfile '/tmp/1890-libvips-8.8.1-linux-x64.tar.gz' -> '/home/developer/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz'
at Object.copyFileSync (fs.js:1728:3)
at WriteStream.<anonymous> (/home/developer/projects/gatsby-test/node_modules/sharp/install/libvips.js:104:16)
at WriteStream.emit (events.js:198:13)
at lazyFs.close (internal/fs/streams.js:207:14)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
make: Entering directory '/home/developer/projects/gatsby-test/node_modules/sharp/build'
TOUCH Release/obj.target/libvips-cpp.stamp
CXX(target) Release/obj.target/sharp/src/common.o
In file included from ../src/common.cc:25:0:
/usr/include/vips/vips8:35:10: fatal error: glib-object.h: No such file or directory
#include <glib-object.h>
^~~~~~~~~~~~~~~
compilation terminated.
sharp.target.mk:129: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/developer/projects/gatsby-test/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.15.0-70-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/developer/projects/gatsby-test/node_modules/sharp
gyp ERR! node -v v10.17.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.2 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.23.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/developer/.npm/_logs/2019-11-18T16_45_16_026Z-debug.log
ERROR
Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
知道这里发生了什么吗?我看到过去sharp
遇到了一些问题,但是现在应该解决这个问题。我在这里想念什么?
答案 0 :(得分:1)
以下行:
Error: EACCES: permission denied, copyfile '/tmp/1890-libvips-8.8.1-linux-x64.tar.gz' -> '/home/developer/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz'
建议您将tmp文件移动到用户的本地.npm目录时遇到权限错误。在不知道有关哪个用户运行了命令等更多上下文的情况下,很难说出这是为什么。
以下行:
fatal error: glib-object.h: No such file or directory
建议您没有正确安装sharp
或vips
。
npm install sharp
对于Ubuntu:
sudo apt-get install -y libvips-tools
对于Mac:
brew update vips
答案 1 :(得分:1)
您可以通过在终端中运行以下命令来解决此问题...
rm -rf /Users/{username}/.npm/_libvips
brew install vips
rm -rf node_modules
npm install
答案 2 :(得分:0)
我有同样的问题。我通过手动下载软件包并粘贴
解决了该问题从https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz
将库复制到.npm文件夹
sudo cp libvips-8.8.1-linux-x64.tar.gz / home / [您的名字] /。npm / _libvips /
删除损坏的gatsby-test文件夹
运行
再次盖茨比新的盖茨比测试
答案 3 :(得分:0)
要解决此问题,我跑了:
rm -rf node_modules
yarn cache clean
yarn add --dev yarn-upgrade-all
npx yarn-upgrade-all
然后,当我运行升级所有软件包的命令时,我重新安装了从package.json中删除的所有必要软件包。
之后,我运行了gatsby build
和gatsby develop