简体   繁体   English

Javascript:权限被拒绝

[英]Javascript: permission denied

I've followed this tutorial for Rabbitmq in Javascript. 我已经使用Javascript遵循了Rabbitmq的本教程。 These are the codes: https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/javascript-nodejs/src/send.js 这些是代码: https : //github.com/rabbitmq/rabbitmq-tutorials/blob/master/javascript-nodejs/src/send.js

https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/javascript-nodejs/src/receive.js https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/javascript-nodejs/src/receive.js

But, when I try to run them with ./send.js and/or ./recv.js it gives me "Permission denied" error. 但是,当我尝试使用./send.js和/或./recv.js运行它们时, 出现 “权限被拒绝”错误。

I look for some solutions but I don't understand, or I find something about IE (that it's not my case) - plus I don't think the problem is the browser (?) If it's so... why? 我正在寻找一些解决方案,但我不明白,或者我发现了有关IE的某些信息(不是我的情况)-再加上我不认为问题出在浏览器(?),如果这样,为什么?为什么? :/ :/

Well, i think you are wrong with few things... you are trying to run it without node or an interpreter. 好吧,我认为您在几件事上是错的...您正在尝试在没有节点或解释器的情况下运行它。

  • If a file it's not a module like file, you should use node ./file.js 如果文件不是文件之类的模块,则应使用node ./file.js
  • If a file it's a module you must to use something like this var myModule = require('./myModule.js); 如果文件是模块,则必须使用类似var myModule = require('./myModule.js); and use its functions. 并使用其功能。
  • If a file it's a browser script you should use like this <script src="/file.js"></script> and use its functions. 如果文件是浏览器脚本,则应使用<script src="/file.js"></script>并使用其功能。

I don't know that software and how it works, but that are the essentials usages of common javascript files. 我不知道该软件及其运行方式,但这是常见javascript文件的基本用法。

You're trying to run Javascript from the command line. 您正在尝试从命令行运行Javascript。 This answer details how to do it with Node, with instructions from Command Line Javascript . 该答案详细说明了如何使用Node以及命令行Javascript中的说明进行操作。 Here's a quick rundown: 这是一个简短的摘要:

  • Download and install Node 下载并安装节点
  • Create the file hello.js containing just one line: 创建仅包含一行的文件hello.js:
    console.log('Hello, world');
  • Running your program is easy; 运行程序很容易; invoke node on the file containing your program: 在包含程序的文件上调用节点:
    node hello.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM