1

如果我在npm run build本地运行命令并将文件夹拖放build到 netlify 中,那么它是托管的,但它给出了这个大错误。

当我尝试从我的 github 存储库进行持续部署时。这是开头显示的错误

11:51:47 PM: npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
11:54:08 PM: npm ERR! code 1
11:54:08 PM: npm ERR! path /opt/build/repo/node_modules/node-sass
11:54:08 PM: npm ERR! command failed
11:54:08 PM: npm ERR! command sh -c node scripts/build.js
11:54:08 PM: npm ERR! Building: /opt/buildhome/.nvm/versions/node/v16.8.0/bin/node /opt/build/repo/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
11:54:08 PM: npm ERR! make: Entering directory '/opt/build/repo/node_modules/node-sass/build'
11:54:08 PM: npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DLIBSASS_VERSION="3.5.5"' -I/opt/buildhome/.node-gyp/16.8.0/include/node -I/opt/buildhome/.node-gyp/16.8.0/src -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/config -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/openssl/include -I/opt/buildhome/.node-gyp/16.8.0/deps/uv/include -I/opt/buildhome/.node-gyp/16.8.0/deps/zlib -I/opt/buildhome/.node-gyp/16.8.0/deps/v8/include -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -std=gnu++14 -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp
11:54:08 PM: npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DLIBSASS_VERSION="3.5.5"' -I/opt/buildhome/.node-gyp/16.8.0/include/node -I/opt/buildhome/.node-gyp/16.8.0/src -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/config -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/openssl/include -I/opt/buildhome/.node-gyp/16.8.0/deps/uv/include -I/opt/buildhome/.node-gyp/16.8.0/deps/zlib -I/opt/buildhome/.node-gyp/16.8.0/deps/v8/include -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -std=gnu++14 -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast_fwd_decl.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/ast_fwd_decl.o ../src/libsass/src/ast_fwd_decl.cpp
11:54:08 PM: npm ERR!   g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DLIBSASS_VERSION="3.5.5"' -I/opt/buildhome/.node-gyp/16.8.0/include/node -I/opt/buildhome/.node-gyp/16.8.0/src -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/config -I/opt/buildhome/.node-gyp/16.8.0/deps/openssl/openssl/include -I/opt/buildhome/.node-gyp/16.8.0/deps/uv/include -I/opt/buildhome/.node-gyp/16.8.0/deps/zlib -I/opt/buildhome/.node-gyp/16.8.0/deps/v8/include -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -std=gnu++14 -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/backtrace.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/backtrace.o ../src/libsass/src/backtrace.cpp

它在这里结束

11:54:08 PM: npm ERR! gyp ERR! node -v v16.8.0
11:54:08 PM: npm ERR! gyp ERR! node-gyp -v v3.8.0
11:54:08 PM: npm ERR! gyp ERR! not ok
11:54:08 PM: npm ERR! Build failed with error code: 1
11:54:08 PM: npm ERR! A complete log of this run can be found in:
11:54:08 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-08-27T18_24_08_951Z-debug.log
11:54:09 PM: Error during NPM install
11:54:09 PM: Build was terminated: Build script returned non-zero exit code: 1
11:54:09 PM: Failing build: Failed to build site
11:54:09 PM: Finished processing build request in 3m28.53038114s
4

1 回答 1

13

我今天遇到了同样的问题。我意识到 Netlify 现在默认使用 node 16.x,这与 node-sass 和其他依赖项不兼容。

您可以通过转到“部署设置”>“环境”>“编辑变量”并添加NODE_VERSION = [版本号](例如 14 以运行最新的节点 14.x)来强制您的 Netlify 环境中的节点版本。

请参阅https://docs.netlify.com/configure-builds/manage-dependencies/

于 2021-09-01T14:19:32.273 回答