Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Browserify bundle.js错误:exec不是函数_Javascript_Node.js_Npm_Browserify_Samba - Fatal编程技术网

Javascript Browserify bundle.js错误:exec不是函数

Javascript Browserify bundle.js错误:exec不是函数,javascript,node.js,npm,browserify,samba,Javascript,Node.js,Npm,Browserify,Samba,我最近安装了Node.js、npm、samba客户端和browserify。问题是,我的bundle.js文件中出现了一个未捕获的TypeError,我无法解决这个问题 bundle.js:107 Uncaught TypeError: exec is not a function at SambaClient.execute (bundle.js:107) at SambaClient.mkdir (bundle.js:58) at Object.8.samb

我最近安装了Node.js、npm、samba客户端和browserify。问题是,我的bundle.js文件中出现了一个未捕获的TypeError,我无法解决这个问题

bundle.js:107 
    Uncaught TypeError: exec is not a function
    at SambaClient.execute (bundle.js:107)
    at SambaClient.mkdir (bundle.js:58)
    at Object.8.samba-client (bundle.js:1319)
    at s (bundle.js:1)
    at e (bundle.js:1)
    at bundle.js:1
我做了一些研究,发现可能是package.json文件有点错误

{
  "name": "package.json",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "directories": {
    "lib": "lib"
  },
  "dependencies": {
    "child_process": "^1.0.2",
    "debug": "^3.1.0",
    "open": "0.0.5",
    "path": "^0.12.7",
    "samba-client": "^2.0.0",
    "util": "^0.10.3"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
但如果我是诚实的,我不知道该怎么办

这是bundle.js中首先失败的部分:

SambaClient.prototype.execute = function(cmd, cmdArgs, workingDir, cb) {
  var fullCmd = wrap(util.format('%s %s', cmd, cmdArgs));

  var command = ['smbclient', this.getSmbClientArgs(fullCmd).join(' ')].join(' ');

  var options = {
    cwd : workingDir
  };

  **exec(command, options, function(err, stdout, stderr) {**
    var allOutput = (stdout + stderr);
    if(err !== null) {
      err.message += allOutput;
    }
    cb(err, allOutput);
  });
};

希望有人能帮助我

是否正确导入exec函数

const exec  = require('child_process').exec;

为什么在NodeJS代码上使用Browserify?或者您正在尝试从web浏览器使用Samba客户端?完全正确。我正在尝试从web浏览器使用samba客户端。这可能吗?不,不可能,也可能永远不会。浏览器的安全模型不允许这样做。想象一下,一个随机网站可以访问对您的机器可见的Samba共享。。。brrr。你所能做的就是运行一个本地的NodeJS服务器来进行Samba通信,并且有一个基于浏览器的前端来实现这一点。这让人大开眼界。谢谢