V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jzlivioo
V2EX  ›  Node.js

[求助]请教一个问题, travis 上跑测试的时候报错: spawn EACCES

  •  
  •   jzlivioo · 2021-09-23 13:48:38 +08:00 · 5103 次点击
    这是一个创建于 938 天前的主题,其中的信息可能已经有所发展或是发生改变。

    学习 node 中,写了个跑本地 html 的工具,类似于 live-server

    然后在 travis 上跑测试的时候报错了

    4dERHJ.png

    这两个测试用例是用来验证命令行功能的,使用起来大概是server --version这样子

    给这个工具的命令行参数加测试的时候,是读取编译后的 js 文件,然后用 child_process.execFile 来跑这个文件并添加参数,代码如下

    ...
    var cmd = path.join(__dirname, "../lib", "serve.js");
    var exec = require("child_process").execFile;
    ...
    
    function exec_test(args, callback) {
      if (process.platform === "win32")
        exec(process.execPath, [cmd].concat(args), opts, callback);
      else exec(cmd, args, opts, callback);
    }
    
    describe("command line usage", function () {
      it("--version", function (done) {
        exec_test(["--version"], function (error, stdout, stdin) {
          assert(!error, error);
          assert(stdout.indexOf("server") !== -1, "version not found");
          done();
        });
      });
      ...
    
    

    本地跑测试的话是会通过的

    请问这是文件访问权限的问题吗?如何解决呢?

    1 条回复    2021-09-23 13:54:25 +08:00
    xingguang
        1
    xingguang  
       2021-09-23 13:54:25 +08:00
    权限问题,要么用 sudo 去运行(不推荐),要么给 node 监听的文件夹读写权限 sudo chmod -R a+rwx
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   939 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:34 · PVG 05:34 · LAX 14:34 · JFK 17:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.