Win 安装 nodejieba 踩坑记录

系统版本: Win11
Node 版本: 16.17.0

  1. 先安装 Python 我装的版本是 python-3.11.4-amd64 ,Python2.7不支持提示版本低。 (需要设置环境变量)
  2. 安装 VisualStudio,这个地方大坑,我搞了好久!!! 。
    1. 下载 VS2017 安装C++桌面开发包
    2. 下载 VS2022 安装 MSVS 141 单组件
    3. 添加环境变量 VCTargetsPath
    // 目录地址 
    D:\Microsoft Visual Studio 2022\MSBuild\Microsoft\VC\v150
    // 这里我改了安装地址 没改的话有可能在这个文件夹里
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp
    
  3. 安装 node-gyp
  4. 指定配置
npm config set msvs_version 2017
npm config set python python

期间遇到的一些报错

  • 安装 VS 2017 以后提示没找到对应的包
error MSB8020: The build tools for v141 (Platform Toolset = 'v141') ccannot be found. To build using the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". 

很恶心的地方,好像是 node-gyp 找包的方式和新版本的包安装地点不一样,总之不能用。
2017里带的 MSVS 是140,所以这里借助了2022安装 141。

  • 装了 VS 2022 找不到MSVS工具包
npm ERR! D:\Microsoft Visual Studio 2022\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.ToolsetLocation.props(98,3): error MSB4019: �Ҳ����������Ŀ��D:\Microsoft Visual Studio 2022\MSBuild\Microsoft\VC\v170Platforms\x64\Platform.props������ȷ�� Import ������D:\Microsoft Visual Studio 2022\MSBuild\Microsoft\VC\v170Platforms\x64\Platform.props���еı���ʽ��ȷ�����ļ�λ�ڴ����ϡ� [D:\Work\exam\node_modules\nodejieba\build\nodejieba.vcxproj]

给环境变量试一试,VCTargetsPath就能找到,但是版本对应的不同不能同,比如2017需要对应141, 140就不行。

  • 尝试不同版本的 VS
    2022版本,需要对应的包是 143, 但是这个包装在那了,我TM找不到。现在回看可能在 D:\Microsoft Visual Studio 2022\MSBuild\Microsoft\VC 目录下 ,又兴趣挑战一下最佳实践可以试试,若可以,希望能留言共同进步。

总结一下,最开始走了好多坑,遇到报错查资料是一方面,另一方面更重要的问题是:注意看报错提示!!!!!!!!!!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
NodeJieba "结巴"分词的Node.js版本Introduction NodeJieba只是CppJieba简单包装而成的node扩展,用来进行中文分词。 详见NodeJiebaBlogInstallnpm install nodejieba 因为npm速度很慢而且经常因为墙的原因出现莫名其妙的问题,在此强烈建议使用cnpm,命令如下:npm --registry=http://r.cnpmjs.org install nodejieba默认分词算法初始化var segment = require("nodejieba"); segment.loadDict("./node_modules/nodejieba/dict/jieba.dict.utf8", "./node_modules/nodejieba/dict/hmm_model.utf8");阻塞式调用var wordList = segment.cutSync("阻塞模式分词"); if (wordList.constructor == Array) // just for tutorial, this is always be true  {     wordList.forEach(function(word) { console.log(word);          }); }非阻塞式调用segment.cut("非阻塞模式分词", function(wordList) {     wordList.forEach(function(word) { console.log(word);          }); });初始化var segment = require("nodejieba"); segment.queryLoadDict("./node_modules/nodejieba/dict/jieba.dict.utf8", "./node_modules/nodejieba/dict/hmm_model.utf8");阻塞式调用var wordList = segment.queryCutSync("阻塞模式分词"); if (wordList.constructor == Array) // just for tutorial, this is always be true  {     wordList.forEach(function(word) { console.log(word);          }); }非阻塞式调用segment.queryCut("非阻塞模式分词", function(wordList) {     wordList.forEach(function(word) { console.log(word);          }); }); 具体用法可以参考 test/segment.js test/query_segment.jsTesting 在node v0.10.2下测试通过http://cppjieba-webdemo.herokuapp.com/ (chrome is suggested)ThanksJieba中文分词 标签:nodejieba

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值