Recibo los siguientes errores cada vez que ejecuto npm install en un proyecto vue.js
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 Intenté reinstalar node y npm, pero siempre parece detenerse en node-sass. npm install funciona bien en todos mis proyectos de laravel. Esto solo sucede en los dos proyectos que saqué recientemente, casi en su totalidad Vue.js y mecanografiado, por lo que no estoy seguro de si ese puede ser el problema.
Editar: Intenté eliminar mi versión local, extraer de github y ejecutar npm install nuevamente y obtuve este error. Fue un error un poco gigantesco, así que tuve que eliminar una gran parte para que encajara en la publicación.
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.odraw -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.odraw -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 1Si está utilizando Node 16, cambie node-sass a versiones> = 6.0.1, luego reinstale las dependencias por npm i posible que solucione su problema. Consulte el problema de seguimiento https://github.com/sass/node-sass/issues/3077 .
Si falla, es posible que deba:
rm -rf node_modules package-lock.json npm cache clean --force npm iAsegúrese de que "sass-loader" en sus "devDependencies" (o en "dependencias") no sea una versión anterior. Para mí, tuve que desinstalar "sass-loader" (una versión anterior), y luego instalar "node-sass" y finalmente "sass-loader" (sin forzar ninguna versión).
Lo solucioné agregando estos a mis devDependencies en package.json :
"node-pre-gyp": "0.17.0", "fsevents": "2.2.1"Encontrado en https://github.com/nodejs/node-gyp/issues/2296