npm安装失败gatsby开发博客

时间:2020-05-02 08:59:02

标签: node.js ubuntu npm gatsby node-gyp

我已经花了几个小时来解决我的gatsby开发博客的问题。我从存储库中克隆了它,并以sudo特权运行了npm install,但失败了。谁能告诉我这是什么问题?

这是我得到的错误:

localhost@localhost:~/Desktop/devBlog$ sudo npm install
[sudo] password for hellRaiser: 
npm WARN tarball tarball data for typeface-montserrat@0.0.54 (sha512-Typhap0PWT299+Va0G/8ZtycHMXrH4gBWKfiW977KEBx5rXUUCa70gvqLx1fdA0WAo6bhSAQmo8uc+QFAmjPww==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for typeface-merriweather@0.0.72 (sha512-gO0+fcZ1fTyKUsYY1ltYOOTI6FmBGeEdyIfeQg9NL8aInndk0feiJJVJsKHm/DiyYrnQEezraAQhz/KQoqMGtw==) seems to be corrupted. Trying one more time.

> sharp@0.21.3 install /home/hellRaiser/Desktop/devBlog/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

ERR! sharp EACCES: permission denied, mkdir '/root/.npm'    
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp WARN EACCES current user ("hellRaiser") does not have permission to access the dev dir "/root/.cache/node-gyp/12.16.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/hellRaiser/Desktop/devBlog/node_modules/sharp/.node-gyp"
make: Entering directory '/home/hellRaiser/Desktop/localhost@localhost:~/Desktop/devBlog$ sudo npm install
[sudo] password for hellRaiser: 
npm WARN tarball tarball data for typeface-montserrat@0.0.54 (sha512-Typhap0PWT299+Va0G/8ZtycHMXrH4gBWKfiW977KEBx5rXUUCa70gvqLx1fdA0WAo6bhSAQmo8uc+QFAmjPww==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for typeface-merriweather@0.0.72 (sha512-gO0+fcZ1fTyKUsYY1ltYOOTI6FmBGeEdyIfeQg9NL8aInndk0feiJJVJsKHm/DiyYrnQEezraAQhz/KQoqMGtw==) seems to be corrupted. Trying one more time.

> sharp@0.21.3 install /home/hellRaiser/Desktop/devBlog/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

ERR! sharp EACCES: permission denied, mkdir '/root/.npm'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp WARN EACCES current user ("hellRaiser") does not have permission to access the dev dir "/root/.cache/node-gyp/12.16.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/hellRaiser/Desktop/devBlog/node_modules/sharp/.node-gyp"
make: Entering directory '/home/hellRaiser/Desktop/devBlog/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:25:10: fatal error: vips/vips8: No such file or directory
   25 | #include <vips/vips8>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [sharp.target.mk:138: Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/hellRaiser/Desktop/devBlog/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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.0-26-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/hellRaiser/Desktop/devBlog/node_modules/sharp
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.3 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.21.3 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!     /root/.npm/_logs/2020-05-02T08_52_17_386Z-debug.log
localhost@localhost:~/Desktop/devBlog$ 

devBlog/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:25:10: fatal error: vips/vips8: No such file or directory
   25 | #include <vips/vips8>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [sharp.target.mk:138: Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/hellRaiser/Desktop/devBlog/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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.0-26-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/hellRaiser/Desktop/devBlog/node_modules/sharp
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.21.3 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.21.3 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!     /root/.npm/_logs/2020-05-02T08_52_17_386Z-debug.log
localhost@localhost:~/Desktop/devBlog$ 

1 个答案:

答案 0 :(得分:1)

可能是由于未安装构建工具。我也遇到了此错误,并采取了解决此问题的步骤:

  1. sudo apt-get更新
  2. sudo apt-get install build-essential
  3. sudo apt autoremove(仅在提示时显示)

npm install有效。

我在ubuntu上。如果您使用的是Mac,则可以尝试安装xcode工具。

如果上述方法不起作用,则问题很可能是由于节点的版本不受支持。就我而言,切换到节点版本8.15.0可以正常工作。