简体   繁体   English

macOS Bigsur 上的“npm install”时出现 Node-gyp 错误

[英]Node-gyp error while `npm install` on macos Bigsur

I am getting node-gyp error while doing npm install .我在执行npm install时遇到 node-gyp 错误。 It's mainly happening when a project has node-sass or env-cmd these kind of dependencies.它主要发生在项目具有node-sassenv-cmd这类依赖项时。 While trying to install env-cmd package or node-sass it's getting this errors.尝试安装 env-cmd 包或 node-sass 时出现此错误。 I am using macos bigsur v11.6.1.我正在使用macos bigsur v11.6.1. node version v16.14.0 . node version v16.14.0 Can anybody help ?有人可以帮忙吗?

  npm ERR! ../src/libsass/src/ast.hpp:1616:14: note: use reference type 'const 

    std::string &' to prevent copying
    npm ERR!         for (const auto denominator : denominators)
    npm ERR!              ^~~~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                         &
    npm ERR! 2 warnings generated.
    npm ERR! In file included from ../src/libsass/src/util.cpp:3:
    npm ERR! ../src/libsass/src/ast.hpp:1614:25: warning: loop variable 'numerator' creates a copy from type 'const std::string' [-Wrange-loop-construct]
    npm ERR!         for (const auto numerator : numerators)
    npm ERR!                         ^
    npm ERR! ../src/libsass/src/ast.hpp:1614:14: note: use reference type 'const std::string &' to prevent copying
    npm ERR!         for (const auto numerator : numerators)
    npm ERR!              ^~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                         &
    npm ERR! ../src/libsass/src/ast.hpp:1616:25: warning: loop variable 'denominator' creates a copy from type 'const std::string' [-Wrange-loop-construct]
    npm ERR!         for (const auto denominator : denominators)
    npm ERR!                         ^
    npm ERR! ../src/libsass/src/ast.hpp:1616:14: note: use reference type 'const std::string &' to prevent copying
    npm ERR!         for (const auto denominator : denominators)
    npm ERR!              ^~~~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                         &
    npm ERR! 2 warnings generated.
    npm ERR! In file included from ../src/libsass/src/values.cpp:3:
    npm ERR! In file included from ../src/libsass/src/values.hpp:4:
    npm ERR! ../src/libsass/src/ast.hpp:1614:25: warning: loop variable 'numerator' creates a copy from type 'const std::string' [-Wrange-loop-construct]
    npm ERR!         for (const auto numerator : numerators)
    npm ERR!                         ^
    npm ERR! ../src/libsass/src/ast.hpp:1614:14: note: use reference type 'const std::string &' to prevent copying
    npm ERR!         for (const auto numerator : numerators)
    npm ERR!              ^~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                         &
    npm ERR! ../src/libsass/src/ast.hpp:1616:25: warning: loop variable 'denominator' creates a copy from type 'const std::string' [-Wrange-loop-construct]
    npm ERR!         for (const auto denominator : denominators)
    npm ERR!                         ^
    npm ERR! ../src/libsass/src/ast.hpp:1616:14: note: use reference type 'const std::string &' to prevent copying
    npm ERR!         for (const auto denominator : denominators)
    npm ERR!              ^~~~~~~~~~~~~~~~~~~~~~~~
    npm ERR!                         &
    npm ERR! 2 warnings generated.
    npm ERR! In file included from ../src/binding.cpp:1:
    npm ERR! In file included from ../../nan/nan.h:58:
    npm ERR! In file included from /Users/macbookpro/.node-gyp/16.14.0/include/node/node.h:63:
    npm ERR! In file included from /Users/macbookpro/.node-gyp/16.14.0/include/node/v8.h:30:
    npm ERR! /Users/macbookpro/.node-gyp/16.14.0/include/node/v8-internal.h:492:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
    npm ERR!             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
    npm ERR!                                 ~~~~~^~~~~~~~~~~
    npm ERR!                                      remove_cv
    npm ERR! /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:710:50: note: 'remove_cv' declared here
    npm ERR! template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
    npm ERR!                                                  ^
    npm ERR! 1 error generated.
    npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1
    npm ERR! gyp ERR! build error 
    npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
    npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/macbookpro/Desktop/V2 projects/ecrm/latest/ecrm-training-frontend/node_modules/node-gyp/lib/build.js:262:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    npm ERR! gyp ERR! System Darwin 20.6.0
    npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/macbookpro/Desktop/V2 projects/ecrm/latest/ecrm-training-frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    npm ERR! gyp ERR! cwd /Users/macbookpro/Desktop/V2 projects/ecrm/latest/ecrm-training-frontend/node_modules/node-sass
    npm ERR! gyp ERR! node -v v16.14.0
    npm ERR! gyp ERR! node-gyp -v v3.8.0
    npm ERR! gyp ERR! not ok 
    npm ERR! Build failed with error code: 1

From the comment by @alex-scott you can see many details.从@alex-scott 的评论中,您可以看到许多细节。

What solved it for me was manual download: https://github.com/nodejs/node-gyp/blob/HEAD/macOS_Catalina.md#installing-node-gyp-using-the-xcode-command-line-tools-via-manual-download为我解决的是手动下载: https ://github.com/nodejs/node-gyp/blob/HEAD/macOS_Catalina.md#installing-node-gyp-using-the-xcode-command-line-tools-via -手动下载

I downloaded the most recent version that does not require Monterey.我下载了不需要 Monterey 的最新版本。 Command_Line_Tools_for_Xcode_13.2.dmg

xcode-select --install did NOT install the correct version. xcode-select --install没有安装正确的版本。

I solve this error, I only need to use the command我解决了这个错误,我只需要使用命令

yarn add node-sass

This update the node-sass and solve all the errors inside the packages when we try to install everything当我们尝试安装所有内容时,这会更新 node-sass 并解决包内的所有错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM