32

I'm getting the following errors whenever I run npm install on a vue.js project

5769 error code 1
5770 error path /*my path*/node_modules/node-sass
5771 error command failed
5772 error command sh -c node scripts/install.js
5773 error /*my path*/node_modules/request/index.js:30
5773 error   if (options !== null && typeof op
5773 error
5773 error
5773 error SyntaxError: Unexpected end of input
5773 error     at Object.compileFunction (node:vm:352:18)
5773 error     at wrapSafe (node:internal/modules/cjs/loader:1031:15)
5773 error     at Module._compile (node:internal/modules/cjs/loader:1065:27)
5773 error     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
5773 error     at Module.load (node:internal/modules/cjs/loader:981:32)
5773 error     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
5773 error     at Module.require (node:internal/modules/cjs/loader:1005:19)
5773 error     at require (node:internal/modules/cjs/helpers:102:18)
5773 error     at Object.<anonymous> (/*my path*/node_modules/node-sass/scripts/install.js:10:13)
5773 error     at Module._compile (node:internal/modules/cjs/loader:1101:14)
5774 verbose exit 1

I've tried reinstalling node and npm, but it always seems to stop on node-sass. npm install runs just fine on all my laravel projects. This only happens on the two projects that I've pulled recently that almost entirely Vue.js and typescript so I'm not sure if that may be the issue.

Edit: I tried delete my local version, pull from github and run npm install again and got this error. It was a bit of a mammoth error so I've had to delet a big chunk of it to fit it into the post.

2863 error code 1
2864 error path /*my path*/node_modules/node-sass
2865 error command failed
2866 error command sh -c node scripts/build.js
2867 error Building: /opt/homebrew/Cellar/node/16.10.0/bin/node /Users/scott/Dev/KPro/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
2867 error   c++ '-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_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.5.5"' -I/Users/scott/.node-gyp/16.10.0/include/node -I/Users/scott/.node-gyp/16.10.0/src -I/Users/scott/.node-gyp/16.10.0/deps/openssl/config -I/Users/scott/.node-gyp/16.10.0/deps/openssl/openssl/include -I/Users/scott/.node-gyp/16.10.0/deps/uv/include -I/Users/scott/.node-gyp/16.10.0/deps/zlib -I/Users/scott/.node-gyp/16.10.0/deps/v8/include -I../src/libsass/include  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -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
2867 error   c++ '-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_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.5.5"' -I/Users/scott/.node-gyp/16.10.0/include/node -I/Users/scott/.node-gyp/16.10.0/src -I/Users/scott/.node-gyp/16.10.0/deps/openssl/config -I/Users/scott/.node-gyp/16.10.0/deps/openssl/openssl/include -I/Users/scott/.node-gyp/16.10.0/deps/uv/include -I/Users/scott/.node-gyp/16.10.0/deps/zlib -I/Users/scott/.node-gyp/16.10.0/deps/v8/include -I../src/libsass/include  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -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

2868 error gyp info it worked if it ends with ok
2868 error gyp verb cli [
2868 error gyp verb cli   '/opt/homebrew/Cellar/node/16.10.0/bin/node',
2868 error gyp verb cli   '/*my path*/node_modules/node-gyp/bin/node-gyp.js',
2868 error gyp verb cli   'rebuild',
2868 error gyp verb cli   '--verbose',
2868 error gyp verb cli   '--libsass_ext=',
2868 error gyp verb cli   '--libsass_cflags=',
2868 error gyp verb cli   '--libsass_ldflags=',
2868 error gyp verb cli   '--libsass_library='
2868 error gyp verb cli ]
2868 error gyp info using node-gyp@3.8.0
2868 error gyp info using node@16.10.0 | darwin | arm64
2868 error gyp verb command rebuild []
2868 error gyp verb command clean []
2868 error gyp verb clean removing "build" directory
2868 error gyp verb command configure []
2868 error gyp verb check python checking for Python executable "python2" in the PATH
2868 error gyp verb `which` succeeded python2 /usr/bin/python2
2868 error gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.16
2868 error gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
2868 error gyp verb get node dir no --target version specified, falling back to host node version: 16.10.0
2868 error gyp verb command install [ '16.10.0' ]
2868 error gyp verb install input version string "16.10.0"
2868 error gyp verb install installing version: 16.10.0
2868 error gyp verb install --ensure was passed, so won't reinstall if already installed
2868 error gyp verb install version is already installed, need to check "installVersion"
2868 error gyp verb got "installVersion" 9
2868 error gyp verb needs "installVersion" 9
2868 error gyp verb install version is good
2868 error gyp verb get node dir target node version installed: 16.10.0
2868 error gyp verb build dir attempting to create "build" dir: /Users/scott/Dev/KPro/node_modules/node-sass/build
2868 error gyp verb build dir "build" dir needed to be created? /Users/scott/Dev/KPro/node_modules/node-sass/build
2868 error gyp verb build/config.gypi creating config file
2868 error gyp verb build/config.gypi writing out config file: /*my path*/node_modules/node-sass/build/config.gypi
2868 error (node:57324) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
2868 error (Use `node --trace-deprecation ...` to show where the warning was created)
2868 error gyp verb config.gypi checking for gypi file: /*my path*/node_modules/node-sass/config.gypi
2868 error gyp verb common.gypi checking for gypi file: /*my path*/node_modules/node-sass/common.gypi
2868 error gyp verb gyp gyp format was not specified; forcing "make"
2868 error gyp info spawn /usr/bin/python2
2868 error gyp info spawn args [
2868 error gyp info spawn args   '/*my path*/node_modules/node-gyp/gyp/gyp_main.py',
2868 error gyp info spawn args   'binding.gyp',
2868 error gyp info spawn args   '-f',
2868 error gyp info spawn args   'make',
2868 error gyp info spawn args   '-I',
2868 error gyp info spawn args   '/*my path*/node_modules/node-sass/build/config.gypi',
2868 error gyp info spawn args   '-I',
2868 error gyp info spawn args   '/*my path*/node_modules/node-gyp/addon.gypi',
2868 error gyp info spawn args   '-I',
2868 error gyp info spawn args   '/Users/scott/.node-gyp/16.10.0/include/node/common.gypi',
2868 error gyp info spawn args   '-Dlibrary=shared_library',
2868 error gyp info spawn args   '-Dvisibility=default',
2868 error gyp info spawn args   '-Dnode_root_dir=/Users/scott/.node-gyp/16.10.0',
2868 error gyp info spawn args   '-Dnode_gyp_dir=/Users/scott/Dev/KPro/node_modules/node-gyp',
2868 error gyp info spawn args   '-Dnode_lib_file=/Users/scott/.node-gyp/16.10.0/<(target_arch)/node.lib',
2868 error gyp info spawn args   '-Dmodule_root_dir=/*my path*/node_modules/node-sass',
2868 error gyp info spawn args   '-Dnode_engine=v8',
2868 error gyp info spawn args   '--depth=.',
2868 error gyp info spawn args   '--no-parallel',
2868 error gyp info spawn args   '--generator-output',
2868 error gyp info spawn args   'build',
2868 error gyp info spawn args   '-Goutput_dir=.'
2868 error gyp info spawn args ]
2868 error gyp verb command build []
2868 error gyp verb build type Release
2868 error gyp verb architecture arm64
2868 error gyp verb node dev dir /Users/scott/.node-gyp/16.10.0
2868 error gyp verb `which` succeeded for `make` /usr/bin/make
2868 error gyp info spawn make
2868 error gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]

2868 error 2 warnings generated.
2868 error In file included from ../src/libsass/src/ast_fwd_decl.cpp:1:
2868 error ../src/libsass/src/ast.hpp:1614:25: warning: loop variable 'numerator' creates a copy from type 'const std::__1::basic_string<char>' [-Wrange-loop-construct]
2868 error         for (const auto numerator : numerators)
2868 error                         ^
2868 error ../src/libsass/src/ast.hpp:1614:14: note: use reference type 'const std::__1::basic_string<char> &' to prevent copying
2868 error         for (const auto numerator : numerators)
2868 error              ^~~~~~~~~~~~~~~~~~~~~~
2868 error                         &
2868 error ../src/libsass/src/ast.hpp:1616:25: warning: loop variable 'denominator' creates a copy from type 'const std::__1::basic_string<char>' [-Wrange-loop-construct]
2868 error         for (const auto denominator : denominators)
2868 error                         ^
2868 error ../src/libsass/src/ast.hpp:1616:14: note: use reference type 'const std::__1::basic_string<char> &' to prevent copying
2868 error         for (const auto denominator : denominators)
2868 error              ^~~~~~~~~~~~~~~~~~~~~~~~



2868 error                                      remove_cv
2868 error /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:776:50: note: 'remove_cv' declared here
2868 error template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
2868 error                                                  ^
2868 error 1 error generated.
2868 error make: *** [Release/obj.target/binding/src/binding.o] Error 1
2868 error gyp ERR! build error
2868 error gyp ERR! stack Error: `make` failed with exit code: 2
2868 error gyp ERR! stack     at ChildProcess.onExit (/*my path*/node_modules/node-gyp/lib/build.js:262:23)
2868 error gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
2868 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
2868 error gyp ERR! System Darwin 20.6.0
2868 error gyp ERR! command "/opt/homebrew/Cellar/node/16.10.0/bin/node" "/*my path*/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2868 error gyp ERR! cwd /*my path*/node_modules/node-sass
2868 error gyp ERR! node -v v16.10.0
2868 error gyp ERR! node-gyp -v v3.8.0
2868 error gyp ERR! not ok
2868 error Build failed with error code: 1
2869 verbose exit 1
Scott Dunn
  • 321
  • 1
  • 3
  • 5

10 Answers10

55

node-sass has been deprecated.

It has been transformed to the npm package sass now.

You can uninstall the old and install the new one

npm uninstall node-sass

npm install sass

Many issues also those during installation have been fixed with this.


Dharman
  • 30,962
  • 25
  • 85
  • 135
Abraham
  • 12,140
  • 4
  • 56
  • 92
  • 1
    Best answer - I was frustrated at every project with node-sass' exhausting installation process. `npm install sass` just works as expected and much faster! – Steven X Sep 22 '22 at 15:09
  • `npm i node-sass` worked fine when accidentally installing to my backend, but gave me errors when installing to the front while following a tutorial. Doesn't bother me using the new version, but I thought that was strange, and the documentation seems to indicate it should still be working for the near future. That could cause a lot of confusion. – Laz Austin Nov 20 '22 at 19:44
21

If you're using Node 16, change node-sass to versions >= 6.0.1, then reinstalling the dependencies by npm i may fixed your problem. See the tracking issue https://github.com/sass/node-sass/issues/3077.

If failed, you may need to:

rm -rf node_modules package-lock.json 
npm cache clean --force
npm i
Jinbo
  • 417
  • 3
  • 10
  • Thank you!! This is the only solution that worked for my M1 machine. – Ye' Thura Ag Dec 27 '21 at 17:40
  • Thanks. Upgraded the package npm i -g node-sass@6.0.1 and it worked like a charm. Later changed it because node-sass was unsupported with piles of issues so used npm uninstall node-sass and did npm install sass. – Kimi Raikkonen 9790 May 11 '22 at 19:12
4

I fixed this by adding these to my devDependencies in package.json:

"node-pre-gyp": "0.17.0",
"fsevents": "2.2.1"

Found in https://github.com/nodejs/node-gyp/issues/2296

Todd Hale
  • 480
  • 8
  • 15
3

If you are still solving this issue Nov 2022 to build Sitecore Habitat for demo/references. Answer for me:

  1. Downgrade your Node JS to 12.22.12. Anything above that, you will hit the same error above.
  2. This will allow you to see the node_modules folder in your habitat solution.
  3. Then you will hit another error on the 'gulp'.

Just follow these steps. I'm on Windows 10 and it worked perfectly for me!

In the same directory where you have package.json create a npm-shrinkwrap.json file with the following contents:

{
  "dependencies": {
    "graceful-fs": {
        "version": "4.2.2"
     }
  }
}

Run npm install, and don't worry, it will update npm-shrinkwrap.json with a bunch of content.

Run gulp to start the project.

It's also worth using nvm, to try other version if you have extra time. Some of my commands I used are as follow.

https://github.com/coreybutler/nvm-windows/releases/tag/1.1.10

https://github.com/nvm-sh/nvm#installing-and-updating

nvm install 12.22.12
nvm use 12.22.12
node -v

npm install -g gulp
npm install
npm uninstall -g gulp
npm uninstall
gulp -v
Marvin Glenn Lacuna
  • 1,682
  • 1
  • 19
  • 25
1

Make sure that "sass-loader" in your "devDependencies" (or in "dependencies") is not an old version. For me, i had to uninstall "sass-loader" (an old version), and then install "node-sass" and finally "sass-loader" (without forcing any version).

Dali
  • 51
  • 3
1

Check the version of node-sass plugin in the package.json file. In my case, it was 4.10.0, and as per the release docs of this version, it supports node version 11, and mine was 16. So either you update the plugin version so that it is compatible with node 16, or you downgrade your node version, so that node becomes compatible with your plugin version.

Sandeep Poonia
  • 2,158
  • 3
  • 16
  • 29
0

None of that worked for me, the only thing that worked was going to an earlier build of npm.

sudo npm install -g n
sudo n 12
npm install

Apparently, the version of assets I was trying to install were too old to work with a current version of npm so downgrading to an earlier version was all that was needed to successfully install.

Now I can work on upgrading things to the latest versions.

elegasoft
  • 28
  • 6
0

None of that worked for me, the only thing that worked was going to an earlier build of npm. sudo npm install -g n sudo n 12 npm install Apparently, the version of assets I was trying to install were too old to work with a current version of npm so downgrading to an earlier version was all that was needed to successfully install. Now I can work on upgrading things to the latest versions.

Solution provided by elegasoft one really works, but you need to uninstall the npm through

sudo npm uninstall -g npm

because the current npm might not works with the older node version, then install the npm again

sudo npm install -g npm
Evu79
  • 1
  • 1
0

I have same problem. And also, in my case, the node-sass is in another dependency package. So I can't remove it directly.

This solution works fine to me:

  1. Install sass using yarn add -D sass if not installed.
  2. Create a folder named dependency-stub in the project root, housing a single file named index.js containing the line module.exports = {}; (which is the stub we will redirect to using resolutions).
  • yarn 2 – add a package.json file to the directory containing { “name: “node-sass”, “version”: “0.0.0” }
  • npm – see note under step 3.
  1. In package.json add “node-sass”: “file:dependency-stub” to the resolutions (or overrides if using NPM) section.
  • npm – use the overrides section rather than resolutions, and since npm file urls are relative to the current dependency, you can either use an absolute path to dependency-stub (possibly placing it in your home directory), a URL for a stub module, or a GitHub URL for a stub module.
  1. In tsconfig.json add “dependency-stub” to the include array (to prevent ESLint from throwing errors regarding the file not being in the project).
  2. npm – assuming dependency-stub isn’t in your project directory, this is not needed.

https://www.openweb.com/blog/preventing-node-sass-or-any-specific-dependency-from-installing

Tychio
  • 591
  • 1
  • 7
  • 20
0
  1. For that above error:

    Step 1: You have to install python 3

    Step 2: Remove package-lock.json file

    Step3: If you are using node version above 18 then change node-sass version to "v9.0.0"

    Step 4: Then, do the npm install

It works for me perfectly.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31