在 Docker 中构建时出现 node-sass 错误

node-sass error when building in Docker

我在构建节点项目时遇到问题,特别是在 node:8.11.4 Docker 容器中编译 sass 时。我收到以下错误:

gyp info using node-gyp@3.8.0
gyp info using node@8.11.4 | linux | x64
.
.
.
In file included from ../src/binding.cpp:3:0:
../src/sass_context_wrapper.h:8:26: fatal error: sass/context.h: No such file or directory
 #include <sass/context.h>
                          ^
compilation terminated.

看来错误是由以下原因引起的:

Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-57_binding.node"

我知道这与代理无关,我尝试直接下载文件,但我也收到了 404。我确保在构建之前删除我的 package-lock.json 文件,以防万一这是 node-sass.

的跨平台版本的问题

有什么办法可以解决这个问题吗?

v3.13.1 上没有 x64-57 的下载,因为 v3.13.1 不支持节点 8。

https://github.com/sass/node-sass/releases/tag/v3.13.1

https://github.com/sass/node-sass/issues/1932

因此您可以更新 node-sass 4.5+ 或将 node.js 降级到 8

以下