You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

私有区块链代码测试与合约部署:npm安装locus报错求助

解决Windows环境安装locus包的postinstall脚本错误

你遇到的核心问题是:在Windows CMD环境下执行npm install locus --save时,locus包的postinstall脚本用了Unix风格的mkdir ./histories命令,而CMD无法正确解析该语法,导致抛出「La syntaxe de la commande n’est pas correcte.」(命令语法不正确)的错误,最终安装失败。

C:\Users\Dell\myApp\peerbet-for-book\peerbet-for-book>npm install locus --save
npm WARN deprecated parse-stack@0.1.4: Use error-stack-parser instead.
deasync@0.1.15 install C:\Users\Dell\myApp\peerbet-for-book\peerbet-for-book\node_modules\deasync
node ./build.js
win32-x64-node-12 exists; testing
Binary is fine; exiting
locus@2.0.1 postinstall C:\Users\Dell\myApp\peerbet-for-book\peerbet-for-book\node_modules\locus
mkdir ./histories
La syntaxe de la commande n’est pas correcte.
npm WARN sportsbet@1.0.0 No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! locus@2.0.1 postinstall: mkdir ./histories
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the locus@2.0.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dell\AppData\Roaming\npm-cache\logs\2019-06-09T14_37_26_080Z-debug.log

下面给你几个实用的解决办法:

  • 方法一:跳过postinstall脚本,手动创建目录
    这是最快捷的方案,用--ignore-scripts参数跳过安装后的脚本执行:

    npm install locus --save --ignore-scripts
    

    安装完成后,手动在你的项目根目录(C:\Users\Dell\myApp\peerbet-for-book\peerbet-for-book)新建一个名为histories的文件夹,locus运行所需的目录就准备好了,完全不影响后续使用。

  • 方法二:用类Unix终端执行安装命令
    如果你电脑上装有Git Bash、WSL(Windows子系统)或者其他支持Unix命令的终端,直接在这些终端里运行原命令:

    npm install locus --save
    

    这类终端能正确识别mkdir ./histories命令,不会出现语法错误。

  • 方法三:修改postinstall脚本(临时方案)
    这个方法适合不想跳过脚本的场景,但需要手动修改包配置:

    1. 先执行原安装命令(即使报错也没关系,locus的文件已经下载到node_modules中)
    2. 找到node_modules/locus/package.json文件,把其中的postinstall字段从mkdir ./histories改成Windows兼容的mkdir histories
    3. 运行npm run postinstall完成后续步骤
      不过这个方法每次重新安装locus都要重复操作,所以优先推荐前两种方法。

另外,安装过程中出现的npm WARN deprecated parse-stack@0.1.4: Use error-stack-parser instead.只是版本过时警告,不会影响包的正常使用,不用过度担心。

内容的提问来源于stack exchange,提问作者Nesryne Turky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:06:01