cnpm/npm 都无法卸载依赖。npm不能安装也不能卸载依赖。只能运行cnpm install. 环境node 10.16.3 npm 6.9.0 * 如果运行npm cache clean --force会报错 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250121/42bf8a166c42039472c26fdb0124385e.png) *** * 如果运行cnpm cache clean --force报错 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250121/efbed96c43b2cff8ed4ea3159ca5d460.png) * 如果cnpm uninstall xxx会报错 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250121/5a16404812895956fa1057bcc75fba55.png)
简单场景下使用mongoDB事务是否合适? 有一个项目使用的是mongoDB作为存储数据库,其中用户充值购买VIP功能(逻辑很简单)打算使用mongoDB中的事务来实现,看官网文档的介绍说使用事务的性能并不好。那这样说在mongoDB中应该避免使用事务吗?(我是mongoDB新手,刚使用这种数据库)
大家在安装仓库依赖时是否遇到过 node-gyp 报错的问题,错误信息大致如下: node_modules/.pnpm/tree-sitter-json@0.20.0/node_modules/tree-sitter-json: Running install script, failed in 586ms .../node_modules/tree-sitter-json install$ node-gyp rebuild │ gyp info it worked if it ends with ok │ gyp info using node-gyp@9.1.0 │ gyp info using node@16.19.1 | darwin | x64 │ gyp info find Python using Python version 3.8.10 found at "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3" │ gyp WARN install got an error, rolling back install │ gyp ERR! configure error │ gyp ERR! stack Error: ENOENT: no such file or directory, stat '/tmp/node-v14.17.6-headers.tar.gz' │ gyp ERR! System Darwin 22.6.0 │ gyp ERR! command "/Users/wangminghui/.nvm/versions/node/v16.19.1/bin/node" "/usr/local/Cellar/pnpm/7.11.0/libexec/dist/node_modules/node-gyp/bin/node-gyp.js" │ gyp ERR! cwd /Users/wangminghui/Documents/xylink-projects/yapi/node_modules/.pnpm/tree-sitter-json@0.20.0/node_modules/tree-sitter-json │ gyp ERR! node -v v16.19.1 │ gyp ERR! node-gyp -v v9.1.0 │ gyp ERR! not ok └─ Failed in 586ms node_modules/.pnpm/tree-sitter-yaml@0.5.0/node_modules/tree-sitter-yaml: Running install script, failed in 561ms .../node_modules/tree-sitter-yaml install$ node-gyp rebuild │ gyp info it worked if it ends with ok │ gyp info using node-gyp@9.1.0 │ gyp info using node@16.19.1 | darwin | x64 │ gyp info find Python using Python version 3.8.10 found at "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3" │ gyp WARN install got an error, rolling back install │ gyp ERR! configure error │ gyp ERR! stack Error: ENOENT: no such file or directory, stat '/tmp/node-v14.17.6-headers.tar.gz' │ gyp ERR! System Darwin 22.6.0 │ gyp ERR! command "/Users/wangminghui/.nvm/versions/node/v16.19.1/bin/node" "/usr/local/Cellar/pnpm/7.11.0/libexec/dist/node_modules/node-gyp/bin/node-gyp.js" │ gyp ERR! cwd /Users/wangminghui/Documents/xylink-projects/yapi/node_modules/.pnpm/tree-sitter-yaml@0.5.0/node_modules/tree-sitter-yaml │ gyp ERR! node -v v16.19.1 │ gyp ERR! node-gyp -v v9.1.0 │ gyp ERR! not ok └─ Failed in 561ms node_modules/.pnpm/fsevents@1.1.2/node_modules/fsevents: Running install script... node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass: Running install script... node_modules/.pnpm/react-slick@0.17.1_wcqkhtmu7mswc6yz4uyexck3ty/node_modules/react-slick: Running postinstall script... ELIFECYCLE Command failed with exit code 1. 找不到 /tmp/node-v14.17.6-headers.tar.gz 文件,确实这个目录下没有这个文件,不清楚为啥要找这个目录下的压缩包,我用的 nvm 管理 node 版本,默认是 v14.17.6,但当前使用的是 v16.19.1,Mac环境。这个项目是 yapi 的官方仓库,但一直下载不好依赖,求助 🙏🙏
现象 1. 项目A:ESM 模块文件中导入 CommonJS 模块文件。运行项目没报错 «"https://stackblitz.com/edit/stackblitz-starters-> pescaa?file=p..." (https://link.segmentfault.com/?enc=RHytx6FgBECDeSI%2BFFJYcg%3D%3D.FwAhcWkSYjSEHFSmmROFh0nI%2BJYMQ8XytSI%2BTBP1AFjtg5ThAADP06beugy20c8oo6YZ4cXamLvmBlfBcNaUp47h05Ak4BqFCqGvclFr3zY%3D)» 2. 项目B:CommonJS 模块文件中导入 ESM 模块文件,运行项目报错 «"https://stackblitz.com/edit/stackblitz-starters-> hujdvx?file=p..." (https://link.segmentfault.com/?enc=l6kDrWL9PrrmkGHxb2u30A%3D%3D.ENTBu%2F1WIHZEwPVoi6QcculOTJW2NtB1VIHpmUKk%2B14krlDFuNfbc9NNU%2Fx4%2Fd3mQahHSfm0ytV339MsXZkuFm62zm3Zh5%2FIoBsLjrFDIS0%3D)» *** 关于 在 "https://nodejs.org/api/packages.html" (https://link.segmentfault.com/?enc=7f%2FmvoF1zwRfL6LbpU2j%2Bg%3D%3D.OW%2FWtT78QiuUJC4R7vLgarYtF9jXCBAMQCiZ4Cug%2F0y9aCuzujHUMQxAtl3IggOn) 中有这样一段内容: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/a6312514ee41c86bdc99e09ae0bfce95.png) 如果以模块的形式导入会使用模块自己的 package.json. 如果以路径的形式化导入会使用被导入文件就近的 package.json. 我的这个理解对不对? *** 问题 我一时也不知道该怎么表述这个问题了。大概就是 ESM 和 CommonJS 互相导入的问题吧。 1. 项目是 ESM,那么项目的某些文件中能不能用 CommonJS、然后在 ESM 中导入 CommonJS?或者项目是 CommonJS,项目的某些文件是 ESM,CommonJS 中能不能导入 ESM? 2. import 本地项目的某一个文件,为什么会使用导入文件附近的 package.json?被导入文件附近的 pacakge.josn 有什么影响? "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/511a518c45b9ea4f9806e37295904ef9.png) 3. 如果是导入模块,是不是一般模块的 package.json 中都会指明使用 CommonJS 语法会导入哪个文件、使用 ESM 语法会导入哪个文件? =============================================== 对于以上的问题 "@然后去远足" (/u/rhqyz) 已经给出了准确的回答。 补充两个问题 另外就是 在 "https://nodejs.org/api/packages.html" (https://link.segmentfault.com/?enc=SlQbPIzEMDeq79xIBp3nRw%3D%3D.xV9FLgoehlZwMen8DBRqF%2F5NY2y%2Fkqj4WCY67LILHv3K5lea5sN1T%2FcQhUWbKIPs) 的开头部分 ES 模块和CommonJS模块的对比中提到了, ES可以 loader commonjs, commonjs不能loader es "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/7524305cc1ea9c82730fb64c6ad8f2a7.png) "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/865ddf70521b382ac46a67d0eb7967ab.png) 补充问题: 1.至于为什么 commonjs 不能loader es,我不确定,chatgpt的回复 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/3402e899c992fa04248fe44ea8d30387.png) "@然后去远足" (/u/rhqyz) 求大佬再帮忙解释一下。 2.让chatgpt给个示例, 他给出的示例中 提到的输出顺序 也搞不懂为什么 顺序不确定。 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/2874f8d826039055752c889af4d44072.png) "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250105/42482817ff364339e8f9c7eeb07200a2.png) 按照我的理解: commonjs的require是同步的,es的import也是同步的。 所以main.js 中 require('./commonjsModule.js'); commonjsModule.js中 require('./es6Module.mjs'); 所以 es6Module.mjs 不是应该先被加载并执行内部的代码吗?
原因是写了typeof xxx == 'array', 虽然不能这么用,但是也不应报错啊,这是babel的bug还是特性? Invalid typeof value: array at createTypeAnnotationBasedOnTypeof (C:\Front\fe\node_modules\@babel\types\lib\builders\flow\createTypeAnnotationBasedOnTypeof.js:29:9) at inferAnnotationFromBinaryExpression (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:107:10) at getConditionalAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:138:20) at getTypeAnnotationBindingConstantViolations (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:35:20) at NodePath._default (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:22:14) at NodePath._getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:77:22) at NodePath.getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:41:15) at NodePath.ConditionalExpression (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferers.js:117:49) at NodePath._getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:77:22) at NodePath.getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:41:15) at NodePath.VariableDeclarator (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferers.js:62:27) at NodePath._getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:77:22) at NodePath.getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:41:15) at getTypeAnnotationBindingConstantViolations (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:44:28) at NodePath._default (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\inferer-reference.js:22:14) at NodePath._getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:77:22) at NodePath.getTypeAnnotation (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:41:15) at NodePath.isGenericType (C:\Front\fe\node_modules\@babel\traverse\lib\path\inference\index.js:136:21) at PluginPass.ForOfStatement (C:\Front\fe\node_modules\@babel\plugin-transform-for-of\lib\index.js:143:48) at newFn (C:\Front\fe\node_modules\@babel\traverse\lib\visitors.js:159:14) at NodePath._call (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:46:20) at NodePath.call (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:36:17) at NodePath.visit (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:82:31) at TraversalContext.visitQueue (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:86:16) at TraversalContext.visitMultiple (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:61:17) at TraversalContext.visit (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:107:19) at traverseNode (C:\Front\fe\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:88:52) at TraversalContext.visitQueue (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:86:16) at TraversalContext.visitSingle (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:65:19) at TraversalContext.visit (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:109:19) at traverseNode (C:\Front\fe\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:88:52) at TraversalContext.visitQueue (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:86:16) at TraversalContext.visitSingle (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:65:19) at TraversalContext.visit (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:109:19) at traverseNode (C:\Front\fe\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:88:52) at TraversalContext.visitQueue (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:86:16) at TraversalContext.visitMultiple (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:61:17) at TraversalContext.visit (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:109:19) at traverseNode (C:\Front\fe\node_modules\@babel\traverse\lib\traverse-node.js:22:17) at NodePath.visit (C:\Front\fe\node_modules\@babel\traverse\lib\path\context.js:88:52) at TraversalContext.visitQueue (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:86:16) at TraversalContext.visitMultiple (C:\Front\fe\node_modules\@babel\traverse\lib\context.js:61:17)
我用electron 实现了一个录屏软件,使用 desktopCapturer 可以录制全屏,但是我想局部或者区域录屏,就不太行,electronjs 好像不能使用 CropTarget 这个类,只能比较曲折的用ffmpeg实现的。大佬们,有什么优雅的方法吗?
抓包魅族社区"https://www.meizu.cn/" (https://link.segmentfault.com/?enc=It8MvyQ0DAaNXEBcZW5Ezg%3D%3D.b75VlS1FPlBlkWOT5AMT97f%2BHiM6gcup%2BduDFmvXn9Q%3D) , 里面有一字段数据是json,需要按规则将key,value转html才能正常显示。求各位指点一下如何实现这种json转html。 这是大概的json数据: [ { "c": [ { "x": "8 月即将过去,9 月即将到来。距离魅族 20 系列发布已经过去了 5 个月时间,在这 5个月的时间里,魅族 20 系列陪你度过了哪些有趣且快乐的时光呢?" } ], "t": "p" }, { "c": [ { "x": "作为魅族最新的全能旗舰,各位在用上它之后,玩原神、打吃鸡、上王者,是否打出过惊为天人的操作?又是否在跑分平台上跑出过其他手机都没有出现过高分成绩呢?" } ], "t": "p" }, { "c": [ { "x": "\n从即日起至8月31日23:59,评论区晒出你的安兔兔跑分成绩,活动结束后,参与晒图跑分活动的魅友将获得 99 煤球奖励,跑分最高者更有机会赢取 999 煤球大奖。" } ], "t": "p" }, { "cv": 0, "s": "https://ssm.res.meizu.com/content/2023/08/28/4018386/140424375354139.jpg", "y": { "h": "1421px", "w": "1080px" }, "c": [ { "x": "" } ], "t": "z" }, ....... ] 规则是这样的: const tr = { t: "type", x: "text", b: "bold", th: "through", y: "style", w: "width", h: "height", s: "src", n: "name", u: "uid", c: "children", l: "italic", r: "url", p: "paragraph", h1: "header1", h2: "header2", h3: "header3", d: "divider", q: "blockquote", v: "video", k: "link", i: "image", m: "mention", tc: "topic", z: "img", cv: "cover", sc: "shopCard" };
请问,付费软件的是否付费这功能是怎么设计/做的呢? 我们知道,很多付费软件如果不付费是不能使用高级功能的。 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20241229/9bee019fe173440c2c2415d91ed6a77d.png) 请问下: 1. 是否有对应的付费验证的设计教程可以参考我们设计实现呢? 2. [联网功能] 比如,这里非付费会员每天可以保存1篇文章,但是我保存第2篇文章的时候,一般是怎么进行验证的,是将自己的userid传输,每次保存时候调用后端API时候,后端都进行先验证再保存吗? 3. [本地功能] 比如,功能在本地软件上,这样的验证是否会员的策略是直接获取API得到是否会员然后进行验证是否可以使用是吗?是否有更好的方法呢?总觉得这个方法不好一样,容易本地破解。
固定有5个字节的16进制,把这5个字节的16进制相加,当然了结果也要是一个字节的16进制 (但是希望大神们给我的方法是不管有几个字节的16进制都能通用) 例如:A5+10+00+01+1E 结果:D4 求教大神们这其中的运算过程该怎么写 小弟在这里先感谢各位大神们,感激不尽,祝大神们发财祝大神们娶漂亮老婆
"image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250108/67b17e94dbc4844548d6ef884ca2ea67.png) 这是一个水塔的svg,需求: 水面跟随进度上升下降 进度低于20时变红色,其余进度变绿色 整体尺寸不是固定的,跟随父布局大小 思路1:目前我的思路是根据进度,切10张水塔图,根据进度动态显示。但这增加包体积,感觉也有点粗暴。 思路2:用两张图上下放置,上面的水塔用clip-path根据进度切,但好像只能且固定大小,因为svg的path好像是固定的 目前没有更好的解决思路,各位大佬怎么看?