位置: IT常识 - 正文

关于node版本16+ 安装依赖会出现error的问题(node最新版本)

编辑:rootadmin
关于node版本16+ 安装依赖会出现error的问题 一、问题描述

推荐整理分享关于node版本16+ 安装依赖会出现error的问题(node最新版本),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:node最新版,node版本太高怎么办,node最新版本,node v12,node的版本,nodeversion,nodeversion,node版本太高怎么办,内容如对您有帮助,希望把文章链接给更多的朋友!

首先正常 yarn add .,发现依赖中node-sass无法正常安装导致编译中断,于是单独安装node-sass,报错如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

npm ERR! code 1

npm ERR! path E:\code\xxxxx_admin_web\node_modules\node-sass

npm ERR! command failed

npm ERR! command C:\Windows\system32\cmd.exe /d /s /c C:\Users\ADMINI~1\AppData\Local\Temp\postinstall-c9fb2595.cmd

npm ERR! Building: D:\nodejs\node.exe E:\code\xxxxx_admin_web\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

npm ERR! gyp info it worked if it ends with ok

npm ERR! gyp verb cli [

npm ERR! gyp verb cli 'D:\\nodejs\\node.exe',

npm ERR! gyp verb cli 'E:\\code\\\xxxxx_admin_web\\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@3.8.0

npm ERR! gyp info using node@16.15.1 | win32 | 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 check python checking for Python executable "python2"in the PATH

npm ERR! gyp verb `which` failed Error: not found: python2

npm ERR! gyp verb `which` failed at getNotFoundError (E:\code\xxxxx_admin_web\node_modules\which\which.js:13:12)

npm ERR! gyp verb `which` failed at F (E:\code\xxxxx_admin_web\node_modules\which\which.js:68:19)

关于node版本16+ 安装依赖会出现error的问题(node最新版本)

npm ERR! gyp verb `which` failed at E (E:\code\xxxxx_admin_web\node_modules\which\which.js:80:29)

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\which\which.js:89:16

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\isexe\index.js:42:5

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\isexe\windows.js:36:5

npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)

npm ERR! gyp verb `which` failed python2 Error: not found: python2

npm ERR! gyp verb `which` failed at getNotFoundError (E:\code\xxxxx_admin_web\node_modules\which\which.js:13:12)

npm ERR! gyp verb `which` failed at F (E:\code\xxxxx_admin_web\node_modules\which\which.js:68:19)

npm ERR! gyp verb `which` failed at E (E:\code\xxxxx_admin_web\node_modules\which\which.js:80:29)

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\which\which.js:89:16

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\isexe\index.js:42:5

npm ERR! gyp verb `which` failed at E:\code\xxxxx_admin_web\node_modules\isexe\windows.js:36:5

npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) {

npm ERR! gyp verb `which` failed code: 'ENOENT'

npm ERR! gyp verb `which` failed }

npm ERR! gyp verb check python checking for Python executable "python"in the PATH

npm ERR! gyp verb `which` succeeded python C:\Program Files\python\python.EXE

npm ERR! gyp ERR! configure error

npm ERR! gyp ERR! stack Error: Command failed: C:\Program Files\python\python.EXE -c import sys; print"%s.%s.%s" % sys.version_info[:3];

npm ERR! gyp ERR! stack File "<string>", line 1

npm ERR! gyp ERR! stack import sys; print"%s.%s.%s" % sys.version_info[:3];

npm ERR! gyp ERR! stack ^

npm ERR! gyp ERR! stack SyntaxError: invalid syntax

npm ERR! gyp ERR! stack

npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:398:12)

npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)

npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16)

npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

npm ERR! gyp ERR! System Windows_NT 10.0.18363

npm ERR! gyp ERR! command"D:\\nodejs\\node.exe""E:\\code\\\xxxxx_admin_web\\node_modules\\node-gyp\\bin\\node-gyp.js""rebuild""--verbose""--libsass_ext=""--libsass_cflags=""--libsass_ldflags=""--libsass_library="

npm ERR! gyp ERR! cwd E:\code\xxxxx_admin_web\node_modules\node-sass

npm ERR! gyp ERR! node -v v16.15.1

npm ERR! gyp ERR! node-gyp -v v3.8.0

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! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-10-09T03_11_39_887Z-debug-0.log

这种情况我们一般都只会说依赖出现问题了。按常规的方法,删除依赖,重新安装

而对出现报错的归因解释得通俗易懂的,可以参考——思否-npm i 运行错误 这个解答

是 node-sass 的问题,这是一个 native 包,默认情况下每个 node 版本都需要单独的 node-sass,一般会从 github release 上下载,你的node版本是 v16.xx.xx ,github release 没有这个版本,所以会转向本地构建,本地构建需要 windows build tools,简单说就是需要安装 visual studio 2019。安装这个后你的环境变量里就可以使用 python 等命令,但是明显你没有,所以会报错

所以针对这个问题,有两种解决思路

二、解决方案(一)、node降级(不推荐)

node切换为v12或者v14的版本

(二)、处理依赖

对依赖的处理方式也有两种方式

参考 CSDN-node16 node-sass 版本

方式一、替换依赖

卸载旧版本的node-sass和sass-loader,安装sass和sass-loader,不再使用node-sass

1

2

npm uninstall sass-loader node-sass

npm install sass-loader@8.0.2 sass@1.26.5 -D

方式二、安装指定版本依赖

安装node16+相对应版本的node-sass和sass-loader

1

npm i node-sass@6.0.1 sass-loader@10.2.0

如果使用方法二之后报错,可能是安装过程中某些包丢失,尝试以下方法解决:

1

npm rebuild node-sass

## 根据自己使用的nodejs版本情况,选择node-sass和sass-loader对应的版本。

>node 12.x-14.x版本对应如下sass版本:

node-sass@4.14.1 (全局安装使用,不用安装到项目):npm install node-sass@4.14.1 -g

sass-loader@8.0.2 (全局安装使用,不用安装到项目):npm install sass-loader@8.0.2 -g

dart-sass@1.25.0 (项目中):npm intsall dart-sass@1.25.0

>node 16.x版本对应如下sass版本:

node-sass@6.0.1 (全局安装使用,不用安装到项目):npm install node-sass@6.0.1 -g

sass-loader@10.2.1 (全局安装使用,不用安装到项目):npm install sass-loader@10.2.1 -g

dart-sass@1.25.0 (项目中):npm intsall dart-sass@1.25.0

解决了Cannot read properties of undefined (reading ‘parseComponent‘)

Vue中eslint报错的修改,绝对有效!!!

Syntax Error: TypeError: Cannot read properties of undefined (reading 'parseComponent')

You may use special comments to disable some warnings.

Use // eslint-disable-next-line to ignore the next line.

Use /* eslint-disable */ to ignore all warnings in a file.

1

2

3

4

5

方法一:

1.找到文件 .eslintrc.js文件,如下图,把 '@vue/standard’注释掉

方法二:

1.找到文件 vue.config.js

修改lintOnSave 为false,如果没有就添加vue.config.js这个文件并把 lintOnSave 设置为false

方法三:

就是所谓的在build/webpack.base.conf.js文件中,注释或者删除掉:module->rules中有关eslint的规则,(我有这个文件但是内容空空白白,然并软,这张图复制别人的,位置就是那里)

方法四:

以上三种方式都无效的我,浪费一下午找的,最后差点信了有些人的鬼话想去卸载脚手架vue-cli,我真是服了那些出馊主意的人,最后这个方式解决了,

1、 yarn add vue-template-compiler

或 npm add vue-template-compiler

2、最后如果还是不行就再用

yarn upgrade –latest vue-template-compiler

npm upgrade –latest vue-template-compiler

最近多次遇到这个问题,node16+版本安装或者初始化带有node-sass和sass-loader包的项目报错。翻遍了所有相关文章,总结出以下两种解决办法:

方法一:

卸载旧版本的node-sass和sass-loader,安装sass和sass-loader,不再使用node-sass

npm uninstall sass-loader node-sass

npm install sass-loader@8.0.2 sass@1.26.5 -D

方法二:

安装node16+相对应版本的node-sass和sass-loader

npm i node-sass@6.0.1 sass-loader@10.2.0

如果使用方法二之后报错,可能是安装过程中某些包丢失,尝试以下方法解决:

npm rebuild node-sass

本文链接地址:https://www.jiuchutong.com/zhishi/298813.html 转载请保留说明!

上一篇:Vue3 使用 JSX(笔记自用)(vue3技巧)

下一篇:手把手教你用UNet做医学图像分割系统(手把手教你用Excel制作考勤表)

  • 收购未税矿产品代扣代缴的资源税计入成本吗
  • 需要出口
  • 小微企业所得税优惠政策最新2022
  • 手机个人所得税app下载官网
  • 增值税专用发票的税率是多少啊
  • 增值税票是什么
  • 我公司租了个人的房子如何入账
  • 小规模申请专票的申请理由怎么写
  • 出口不退税进项税如何处理
  • 私企招残疾人可以辞职吗
  • 增值税的附加税率是多少
  • 出租的城镇土地由谁交城镇土地使用税
  • 发票不附销货清单可以吗
  • 收到借款确认书模板
  • 周转材料租赁费怎么结转成本
  • 免费送客户礼品的文案
  • 补去年收入的会计分录
  • 公司用货币资金做账
  • 项目现金流量的构成
  • 已提完折旧车辆可以卖吗
  • 企业利润分配如何分析
  • 通用机打发票操作流程
  • 增值税发票开票有误怎么办?
  • 预征税额是什么意思
  • 小规模国税地税怎么交
  • 以现金形式发放的员工餐费补贴,可并入职工福利费
  • 公益组织接受捐赠怎么开票
  • 先计提社保还是先计提工资
  • world超链接
  • 公司章程签署
  • 小规模计提增值税的会计科目
  • 入库单做账是预付款还是应付款
  • 如何安装电脑系统程序
  • linux管理员账户名
  • 苹果发布首款MR头显
  • win10显示无法连接蓝牙
  • 外贸企业代理出口销售的出口退税手续
  • 固定资产增加应计入什么
  • 汇算清缴补交的所得税怎么记帐
  • 卡格拉河
  • 芒果sdk
  • 集团公司对子公司的内部审计
  • 租金发票的税率多少
  • 个人接受现金捐赠的情况
  • 销售折让怎么核算成本
  • Android ViewPager2 + Fragment 联动
  • 金税盘的维护费怎么报税
  • 公司新装宽带怎么安装
  • 厂家核销费用直接扣除吗
  • 实名汽车票抵扣
  • 库存商品账务没做如何调增
  • 房地产项目企业
  • 产品成本核算方法受那些因素影响
  • 企业预付账款的分录
  • sql语句中having是什么意思
  • mysql运行代码
  • Windows Server 2003环境更改Boot.ini文件
  • windows xp退役
  • windows7 设置
  • ubuntu虚拟机怎么联网
  • ubuntu的root
  • linux系统中怎么创建目录
  • windows7右下角网络图标不见了怎么办
  • win10自定义你的设备有什么用
  • windows8安装步骤
  • win10的显示
  • javascript教程推荐知乎
  • jquery实现搜索功能
  • linux awk命令使用实例
  • 纵向导航页面
  • jquery结合html实现中英文页面切换
  • vuex状态机
  • 编写js代码要注意什么
  • python读入txt
  • python项目打包发布
  • 低保大数据核查哪些数据
  • 物业公司收取的物业费用如何缴税
  • 网上交了购置税你要打印出来吗
  • 湖北职称网上申请流程
  • 草原补偿标准
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设