Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'? #38367

Closed
AirWSW opened this issue Apr 23, 2021 · 18 comments
Labels
wrong repo Issues that should be opened in another repository.

Comments

@AirWSW
Copy link

AirWSW commented Apr 23, 2021

  • Version:v16.0.0
  • Platform:Darwin 20.3.0 arm64 (Apple Silicon)

What steps will reproduce the bug?

When building node-sass@5.0.0, the error occurred.

How often does it reproduce? Is there a required condition?

ALWAYS, arm64 (Apple Silicon)

What is the expected behavior?

NO error

What do you see instead?

/Users/***/Library/Caches/node-gyp/16.0.0/include/node/v8-internal.h:452:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
            !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:697:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/***/*/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/opt/homebrew/Cellar/node/16.0.0/bin/node" "/Users/***/*/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/***/*/node_modules/node-sass
gyp ERR! node -v v16.0.0

Additional information

Here is the ref link:

V8_INLINE void PerformCastCheck(T* data) {
CastCheck<std::is_base_of<Data, T>::value &&
!std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
}

When replacing remove_cv_t with remove_cv, it seems to work well.

@XadillaX
Copy link
Contributor

I think it's a bug of node-sass.

Refs: microsoft/node-pty#441 (comment) and microsoft/node-pty#433

@Ayase-252
Copy link
Member

I think Node.js v16 isn't supported by node-sass@5.0.0 from the release note.

There is also an ongoing issue sass/node-sass#3077 in order to support Node.js v16.

If you need to use node-sass now, I'd suggest to revert to the latest Node v14 LTS.

@Ayase-252 Ayase-252 added the wrong repo Issues that should be opened in another repository. label Apr 23, 2021
@AirWSW
Copy link
Author

AirWSW commented Apr 23, 2021

Thanks!

The latest Node v14 LTS has not supported Apple Silicon natively, while v16 is the best choice for me. Fortunately, I found that sass/node-sass#3091 is trying to upgrade the cpp standard to 14, thereby fixing the macOS building errors.

@Daavidaviid
Copy link

Daavidaviid commented Apr 26, 2021

I'm downgrading to 15.14 following : https://michael.codes/posts/nodejs_apple_silicon/
Hopefully it will work 🤞

EDIT: it worked, but my macbook air m1 got really hot during the node build (>10mins)

@bryanvaz
Copy link

Ok managed to "solve" the issue.
The issue seems to be tied to the cpp compiler specified by the dependency's bindings.gyp when building native addons on Apple Silicon.

TLDR (though may have unexpected consequences)

yarn install -std=c++17

This arises, because remove_cv_t is only supported since C++14 (ref). For whatever reason, Node 16, when paired with cpp on Apple Silicon does not have the ability to properly resolve the incorrect remove_cv_t reference if cpp is given a language flag that is less than -std=c++14 (i.e. -std=c++11 in the case ofnode-sass.)

Obviously the best option would be to submit PRs to bump the cpp flags of dependencies. However for dependencies deep in the tree, this can take sometimes months or years bubble up to the top-level dependency. Brute forcing the cpp flags seems to be the only option until the environment shakes out.

Not sure what the equivalent npm command should be, but if someone who is more familiar with npm can post the correct flag, that would be great.

Thanks to @stevecondylios for the solution, from microsoft/node-pty#441 (comment) for the solution

@litobear
Copy link

litobear commented Nov 1, 2021

RUN CXXFLAGS="--std=c++14" npm install

It is work for me

@ellipsistechnology
Copy link

FYI, I'm experiencing this issue on an Intel based Mac also. Downgrading to node 14 fixed the issue though.

@worksofliam
Copy link

On m1 mac, using Node.js 16.7, with a project that has node-sass, the following worked:

CXXFLAGS="--std=c++14" yarn

Thank you @litobear

@gotcha
Copy link

gotcha commented Dec 15, 2021

CXXFLAGS="--std=c++14" npm install worked for me as well on Intel Mac

@zdonato
Copy link

zdonato commented Jan 31, 2022

Can confirm CXXFLAGS="--std=c++14" npm install works on Mac with Node v17.4.0 as well

@jdbranham
Copy link

Also works for WSL2

node -v
v16.13.1

npm -v
8.5.1


CXXFLAGS="--std=c++14" npm rebuild node-sass

@lialia-siterocket
Copy link

lialia-siterocket commented Feb 21, 2022

Works
CXXFLAGS="--std=c++14" npm install
M1 node 17!

@joeyguerra
Copy link

yarn install -std=c++17 worked for me, Mac Mini M1. Node 17.8.0

@dheeraj-upadhyay
Copy link

May be i haven't fully understood it, the solution that is proposed in the thread with npm to set CXXFLAGS="--std=c++14" is a workaround, right ? But what about the permanent fix for this ? We can't set this flag while running the npm ci in pipelines. Please suggest a permanent fix for this.

@joeyguerra
Copy link

#38367 (comment)

^^^ comment explains the situation pretty well.

I'm happy to pair with you on a fix if you want to send me a DM.

@dheeraj-upadhyay
Copy link

I saw the comment, actually my use case is i need to upgrade from node 14 to node 16 and by doing so it started showing me this error. Mine is an ionic angular application using npm. From some research it was also saying that the issue is related to node-sass incompatibility with the node-16.
Mine issue is resolved by running following :-
CXXFLAGS="--std=c++14" npm install
but do i need to set this flag everytime installing package and what about the ci pipeline - how will it handle npm install ?
Let me know how can i connect with you for DM , my gmail id is dheeraj053@gmail.com

@LittleYe233
Copy link

I have tried Node v16~18 on Manjaro x86_64, and Node v16+CXXFLAGS="--std=c++14" works finally. I don't want to try more combinations any more for its installation has spent me lots of time.

There is an issue and a pull request on support node-sass+Node v18, and it seems it is almost ready for merging to mainline. Hope it can support new version Node.JS better.

The successful try:

  • OS: Manjaro x86_64
  • Node: v16.15.1
  • yarn: v1.22.19
  • gcc: 12.1.0 (from Manjaro package repository)
  • C++ compilation flags: --std=c++14

@alexandracrisan
Copy link

CXXFLAGS="--std=c++17" yarn install
worked for me - node 16

kylef added a commit to apiaryio/drafter that referenced this issue May 17, 2023
NodeJS 16 onwards no longer supports building with c++11

See nodejs/node#38367
kylef added a commit to apiaryio/drafter that referenced this issue May 17, 2023
NodeJS 16 onwards no longer supports building with c++11

See nodejs/node#38367
kylef added a commit to apiaryio/drafter that referenced this issue Jul 28, 2023
NodeJS 16 onwards no longer supports building with c++11

See nodejs/node#38367
tfoote added a commit to lindycollection/www.lindycollection.com that referenced this issue Oct 8, 2023
And bumping all dependencies to the latest

nodejs/node#38367
tfoote added a commit to lindycollection/www.lindycollection.com that referenced this issue Oct 8, 2023
And bumping all dependencies to the latest

nodejs/node#38367
tfoote added a commit to lindycollection/www.lindycollection.com that referenced this issue Oct 8, 2023
And bumping all dependencies to the latest

nodejs/node#38367
tfoote added a commit to lindycollection/www.lindycollection.com that referenced this issue Oct 8, 2023
And bumping all dependencies to the latest

nodejs/node#38367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests