5
votes

We are a team working on a angular project. After downloading the code from repo, when I try to run $npm install, im facing the following error.

I have tried installing node-gyp, node-sass, deleted node_modules under project directory but nothing resolves the issue while executing $npm install

../src/create_string.cpp: In function ‘char* create_string(Nan::MaybeLocal)’: ../src/create_string.cpp:17:37: error: no matching function for call to v8::String::Utf8Value::Utf8Value(v8::Local&)’ v8::String::Utf8Value string(value); ^

In file included from /home/pc-username/.node-gyp/12.7.0/include/node/node.h:63:0,

             from ../../../../../nan/nan.h:54,
             from ../src/create_string.cpp:1:
/home/pc-username/.node-gyp/12.7.0/include/node/v8.h:3002:5: note: candidate: v8::String::Utf8Value::Utf8Value(v8::Isolate*, v8::Local<v8::Value>)
     Utf8Value(Isolate* isolate, Local<v8::Value> obj);
     ^~~~~~~~~

/home/pc-username/.node-gyp/12.7.0/include/node/v8.h:3002:5: note: candidate expects 2 arguments, 1 provided binding.target.mk:127: recipe for target 'Release/obj.target/binding/src/create_string.o' failed

make: *** [Release/obj.target/binding/src/create_string.o] Error 1
make: Leaving directory '/home/pc-username/project-folder/project-name/node_modules/@angular-devkit/build-angular/node_modules/node-sass/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pc-username/project-folder/project-name/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.18.0-25-generic
gyp ERR! command "/usr/lib/node_modules/node/bin/node" "/home/pc-username/project-folder/project-name/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/pc-username/project-folder/project-name/node_modules/@angular-devkit/build-angular/node_modules/node-sass
gyp ERR! node -v v12.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Build failed with error code: 1 npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of font-awesome@^4.7.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular-devkit/build-angular/node_modules/node-sass): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

audited 46047 packages in 162.363s found 641 vulnerabilities (1 low, 640 high) runnpm audit fixto fix them, ornpm auditfor details

Can someone point me what the problem is?

Regards, Ananth S

2

2 Answers

4
votes

Face same issues before probably the issue is from node sass.

Try to delete your package.json.lock and run npm install.

Refer to this link: https://github.com/sass/node-sass/issues/1991

3
votes

if it is of any use for someone having this issue nowadays with the latest versions of angular using Ivy (8+), I was recently struggling with the package-lock.json and node-modules (deleting and reinstalling all multiple times, even updating my node and npm versions to the latest as suggested in the previous answer and many other related questions similar to this one), all of those with no success.

What got it fixed was running

npm audit fix

I think that what happened is that node-sass was replaced in favor of dart-sass as of Angular version 8 https://blog.ninja-squad.com/2019/05/29/angular-cli-8.0/#dart-sass-replaces-node-sass

I noticed in my package-lock.json that no matter how many times I deleted it and retried npm install, node-sass was always an @angular-devkit/build-angular required dependency (whereas in my newer Angular 10 projects created with angular CLI the dependency was plain sass)

After running npm audit fix, my package-lock.jsonwas updated to use sassas required dependency for @angular-devkit/build-angular, same as it is by default in the newer Angular projects.

If anyone has more clarity on why this is the way it is or another better way to solve it, I'd be thrilled to know. Otherwise I hope this helps.

I read about the npm audit fix solution in another similar question in stack overflow I can't seem to find again right now :( I will link it if I see it again, but credits to that guy.