npm install时报一堆错(大致错误范围在sass)

这篇具有很好参考价值的文章主要介绍了npm install时报一堆错(大致错误范围在sass)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在服务器上部署一个react写的网站(windows开发,linux部署)的时候,npm install会报很多错:

npm WARN using --force Recommended protections disabled.
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm ERR! code 1
npm ERR! path /Projects/CLogin/login-frontend/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c -- node scripts/build.js
npm ERR! Building: /program/nvm/nvm-0.39.0/versions/node/v18.12.1/bin/node /Projects/CLogin/login-frontend/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! make: Entering directory '/Projects/CLogin/login-frontend/node_modules/node-sass/build'
npm ERR!   g++ -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp '-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_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DLIBSASS_VERSION="3.5.5"' -I/root/.cache/node-gyp/18.12.1/include/node -I/root/.cache/node-gyp/18.12.1/src -I/root/.cache/node-gyp/18.12.1/deps/openssl/config -I/root/.cache/node-gyp/18.12.1/deps/openssl/openssl/include -I/root/.cache/node-gyp/18.12.1/deps/uv/include -I/root/.cache/node-gyp/18.12.1/deps/zlib -I/root/.cache/node-gyp/18.12.1/deps/v8/include -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -std=gnu++17 -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw   -c
npm ERR! make: Leaving directory '/Projects/CLogin/login-frontend/node_modules/node-sass/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/program/nvm/nvm-0.39.0/versions/node/v18.12.1/bin/node',
npm ERR! gyp verb cli   '/Projects/CLogin/login-frontend/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@18.12.1 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - executable path is "/usr/bin/python3"
npm ERR! gyp verb find Python - executing "/usr/bin/python3" to get version
npm ERR! gyp verb find Python - version is "3.6.8"
npm ERR! gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 18.12.1
npm ERR! gyp verb command install [ '18.12.1' ]
npm ERR! gyp verb install input version string "18.12.1"
npm ERR! gyp verb install installing version: 18.12.1
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 18.12.1
npm ERR! gyp verb build dir attempting to create "build" dir: /Projects/CLogin/login-frontend/node_modules/node-sass/build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /Projects/CLogin/login-frontend/node_modules/node-sass/build/config.gypi
npm ERR! gyp verb config.gypi checking for gypi file: /Projects/CLogin/login-frontend/node_modules/node-sass/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /Projects/CLogin/login-frontend/node_modules/node-sass/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Projects/CLogin/login-frontend/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Projects/CLogin/login-frontend/node_modules/node-sass/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Projects/CLogin/login-frontend/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/18.12.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.12.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Projects/CLogin/login-frontend/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.12.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Projects/CLogin/login-frontend/node_modules/node-sass',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp verb command build []
npm ERR! gyp verb build type Release
npm ERR! gyp verb architecture x64
npm ERR! gyp verb node dev dir /root/.cache/node-gyp/18.12.1
npm ERR! gyp verb `which` succeeded for `make` /usr/bin/make
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: g++: Command not found
npm ERR! make: *** [src/libsass.target.mk:159: Release/obj.target/libsass/src/libsass/src/ast.o] Error 127
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 (/Projects/CLogin/login-frontend/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 4.18.0-193.28.1.el8_2.x86_64
npm ERR! gyp ERR! command "/program/nvm/nvm-0.39.0/versions/node/v18.12.1/bin/node" "/Projects/CLogin/login-frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Projects/CLogin/login-frontend/node_modules/node-sass
npm ERR! gyp ERR! node -v v18.12.1
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-01-13T14_02_28_286Z-debug-0.log

如果你遇见这个问题,我总结了一些解决方案(并行方案,不是步骤):文章来源地址https://www.toymoban.com/news/detail-420900.html

  1. 重新编译node-sass二进制文件:npm rebuild node-sass
  2. 卸载node-sass: npm uninstall node-sass,安装sass:npm install sass。(用sass替换node-sass)
  3. 删除node_modules目录重新npm install
  4. 删除node_modulespackage-lock.json重新npm install
  5. 查看你的node-sass版本是否对应你的node版本(通常会有报错node sass does not yet support your current environment: linux 64-bit with unsupported runtime)
Node 版本 node-sass 版本
Node 17 7.0+
Node 16 6.0+
Node 15 5.0+
Node 14 4.14+
Node 13 4.13+, <5.0
Node 12 4.12+
Node 11 4.10+, <5.0
Node 10 4.9+, <6.0
Node 8 4.5.3+, <5.0
Node <8 <5.0
  1. 如果上面的方法都不行,那么你一定要仔细核对,开发时使用的node版本是否和部署时的一致。注意,并不是简单查看node版本号,发现一样即可,而是要弄清楚你开发环境安装依赖的时候,使用的node版本是否和服务器上一致! 如果你使用过nvm之类的版本管理工具,那么把每个版本都试试,可能你某些时候切换过,但是忘记了。

到了这里,关于npm install时报一堆错(大致错误范围在sass)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • npm install 报错 ERR! gyp ERR! node-sass python

    一、问题描述: npm install 报错 ERR! gyp ERR! ERR! stack Error: Can\\\'t find Python executable \\\"python\\\", you can set the PYTHON env variable node -v v16 node-gyp -v v3.8.0 二、可能原因 1 nodejs与sass版本不匹配(可能性最大:解决办法见三) node版本是16,sass版本是4.14。重装的node ,就好了。其他两个是调查时看到

    2024年02月03日
    浏览(58)
  • 执行npm install时老是安装不成功node-sass的原因和解决方案

    相信你安装前端项目所需要的依赖包(npm install 或 yarn install)时,有可能会出现如下报错: 那么到底是什么原因导致这个问题出现呢? 最多的原因还是 node的版本 和node-sass的版本不一致,比如node版本是 16+的,而你的版本还是旧的 “node-sass”: “^4.14.1”。因为node并不会兼容

    2024年02月06日
    浏览(59)
  • ❤ npm install 时报Error: spawn git ENOENT

    ❤ npm install 时报Error: spawn git ENOENT 原因: 主要是因为由于 git 的环境变量未设置导致,所以安装一下git 的环境变量就O了,步骤如下: 设置 系统 高级系统设置 高级 环境变量 系统变量:添加一下git 的安装地址 在环境变量的path里添加上 C:Program FilesGitcmd 就可以了。路径根

    2024年02月04日
    浏览(267)
  • 使用 npm install安装依赖时报错 npm ERR! Error while executing

    问题描述:vue-element-admin使用 npm install安装依赖时报错 npm ERR! Error while executing 解决办法1:(没有解决我的问题) 执行如下命令: 再执行 npm install 就可以了 如果上述命令执行完后,还是报那个错误,请继续执行如下命令,亲测有效 解决办法2:(解决了我的问题!!!)

    2024年02月11日
    浏览(228)
  • 解决npm install时报错Could not resolve dependency

    最近在新的项目使用npm install时发现报错: npm WARN cli npm v9.6.4 does not support Node.js v15.14.0. This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || =18.0.0`. You can find the latest version at https://nodejs.org/. npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR!  npm ERR! While resolving:

    2024年02月08日
    浏览(48)
  • 安装node-sass失败 或 npm install Error: not found: python2 解决方案

    1. 安装python2 可以用npm命令安装 也可以自行下载安装 Python 2.7 2. 安装完毕后配置环境变量 3.再配置一下版本 node-sass 实在太坑了,之前遇到安装失败使用方法一完美解决。最近又一次遇到了,但是方法一又无效了。于是我又在网上找到另一个方法,就是用 dart-sass 来替换 node

    2024年02月13日
    浏览(93)
  • 解决npm install报错 npm ERR! gyp ERR! cwd D:\Projec\xxx\node_modules\node-sass (node-sass版本问题)

    vue项目换电脑后npm install发现一直报如下的错误: node-sass版本不兼容,比较老。还出现找不到python路径的错误。node-sass 需要 node-gyp安装时需要进行转译所以可能会出现各种按安装问题。且node-sass 本身就已经是deprecated状态了。如果不是维护老项目不建议再使用 由于它只用于开

    2024年02月09日
    浏览(67)
  • npm install时出现的问题Failed at the node-sass@4.14.1 postinstall script

    从阿里云上拉取下来项目后,首先使用npm install 命令进行安装所需依赖,意想不到的事情发生了,报出了Failed at the node-sass@4.14.1 postinstall script,这个问题,顿时一脸懵逼;询问前端大佬,给出的反馈是,“没法解决”,这时我有点不知所措了,大佬都说没法解决了。  但是我

    2024年02月14日
    浏览(53)
  • 快速解决 npm 安装 node-sass 速度慢/错误的问题(nexus私服问题见上一篇博客)

    这通常是因为 node-sass 包中包含有本地二进制文件( _binding.node ),而在某些情况下,下载过程可能会失败。 以下是一些可能的解决方法: 1. 使用淘宝镜像 你可以尝试使用淘宝的 cnpm 命令行工具,该工具使用淘宝的镜像源,可以解决部分下载问题。首先,安装 cnpm : 然后使

    2024年02月03日
    浏览(55)
  • npm install错误——npm ERR! code ERESOLVE 解决方法(亲测有效)

    最近node用nvm来管理,nvm安装在这里   nvm的环境变量   path中配置       正在使用的node版本的软连接在这里  vue项目执行npm install的时候报如下错误 添加--legacy-peer-deps即可正常                

    2024年02月14日
    浏览(54)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包