我试图在netlify上托管我的react网站,但这个npm安装错误来了



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

当我尝试从我的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

我今天遇到了同样的问题。我意识到netflix现在使用的是节点16。它与node-sass和其他依赖不兼容。

您可以通过"Deploy Settings"在您的netflix环境中强制使用节点版本比;"Environment"比;"编辑variables">并添加NODE_VERSION =[版本号](例如14运行节点最新的14.x)。

见https://docs.netlify.com/configure-builds/manage-dependencies/。

相关内容

  • 没有找到相关文章

最新更新