相关疑难解决方法(0)

AWS Lambda错误:"找不到模块'/ var/task/index'"

Node.js Alexa任务问题

我目前正在通过AWS Lambda编写Node.js Alexa任务,我一直在尝试编写一个函数,该函数从OpenWeather API接收信息并将其解析为一个名为的变量weather.相关代码如下:

var request = require('request');
var weather = "";
function isBadWeather(location) {
      var endpoint = "http://api.openweathermap.org/data/2.5/weather?q=" + location + "&APPID=205283d9c9211b776d3580d5de5d6338";
      var body = "";
      request(endpoint, function (error, response, body) {
            if (!error && response.statusCode == 200) {
                  body = JSON.parse(body);
                  weather = body.weather[0].id;
            }
      });
}

function testWeather()
{
      setTimeout(function() {
      if (weather >= 200 && weather < 800)
            weather = true;
      else
            weather = false;
      console.log(weather);
      generateResponse(buildSpeechletResponse(weather, true), {});
      }, 500);
} …
Run Code Online (Sandbox Code Playgroud)

javascript request amazon-web-services node.js aws-lambda

86
推荐指数
4
解决办法
4万
查看次数

索引处理程序未定义或未导出

我有一个运行良好的 lambda 函数,但我想导入一个包,所以我用 index.js 创建了一个目录并安装了我的 npm 包。

然后创建此文件夹的 zip 并使用上传

aws lambda 更新函数代码 --function-name smrtfac-test --zip-file fileb://lambda.zip

但现在我收到这个错误

index.handler is undefined or not exported
Run Code Online (Sandbox Code Playgroud)

原因可能是什么?myindex.jsnode_modules在同一个目录中。

aws-cli aws-lambda

27
推荐指数
2
解决办法
2万
查看次数

批处理文件脚本到zip文件

我有这种模式的文件夹结构.我刚刚在每个子目录中显示了两个子目录和2个文件,但通常我在单个级别上有n个子目录,在它们下面有单个级别的文件(但可以是n个文件).

Directory master
subDirectory x:
  file1
  file2
Directory y:
  file 3
  file 4
Run Code Online (Sandbox Code Playgroud)

我需要创建一个Windows脚本,一个从主目录运行的批处理文件,并给我两个包含各自文件的zip文件x.zip和y.zip.

我知道我的脚本必须使用for和zip命令但我正在试图让它工作,因为我无法理解这些命令的语法和谷歌搜索似乎没有帮助.

我找到了这样的命令, for %f in ("*.*") do zip "%~nf.zip" "%f" 但它似乎只有在没有子文件夹的情况下才直接存在.

windows batch-file

17
推荐指数
5
解决办法
19万
查看次数

在Jenkins管道上缓存NPM依赖项

我们都知道,使用npm下载依赖项会非常耗时,尤其是当我们仅限于旧的npm版本时。

对我而言,作为开发人员,这没什么大不了的,因为我不得不在本地开发计算机上执行几次此操作,并且一切都与我项目文件夹中的node_modules缓存一起使用。但是现在我想通过Jenkins将这些应用程序带到CI环境。

我意识到用npm下载依赖项花费了大量时间。这是一个问题,因为:

  1. npm将依赖项下载到项目文件夹中,而不是Maven的/home/user/.m2之类的全局文件夹中

  2. 我必须在每次运行中清理Jenkins工作区文件夹,以避免git checkout出现问题。

我想要一个非常优雅的解决方案来在我的Jenkins从属服务器上缓存npm依赖项,但是到目前为止,我只能想到:

  1. 从Jenkins工作区中删除除node_modules文件夹之外的所有内容。我不喜欢这样,因为如果我继续为我的项目创建分支,我可能会消耗大量的HDD。每个分支都创建一个工作区。

  2. cp ./node_modules /home/npm_cache在每次npm安装之后,然后cp /home/npm_cache ./node_modules在代码签出之后执行类似的操作。

我觉得这些解决方案很糟糕。必须有更好的方法来做到这一点。

dependencies caching node.js jenkins

7
推荐指数
3
解决办法
3862
查看次数

无法运行npm install browserify

我尝试npm install browserify在本地和全局运行(-g)

但我总是得到以下错误

npm ERR! peerinvalid The package bn.js does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer miller-rabin@1.1.2 wants bn.js@^0.16.0

npm ERR! System Darwin 14.0.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "browserify"
npm ERR! cwd /Users/kanitw/Dropbox/_Projects/_idl/_visrec/vegalite
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/kanitw/Dropbox/_Projects/_idl/_visrec/vegalite/npm-debug.log
npm ERR! not ok code 0
Run Code Online (Sandbox Code Playgroud)

不知道如何解决它. …

install npm browserify

5
推荐指数
1
解决办法
2280
查看次数

Compress-Archive 命令返回“异常:流太长。”

我在这里有一个简单的脚本来存档以名称“存档”开头的日志,然后删除那些只留下存档的文件。

cd L:\

$Source =  Get-ChildItem L:\ | Where{$_.Name -match "^Archive.*\.evtx$"} |Get-ChildItem -name

$CurrentDate = get-date -Format M.d.yyyy

$Destination = "$CurrentDate.zip"

Compress-Archive -Path $Source -destinationpath $Destination

rm L:\$Source
Run Code Online (Sandbox Code Playgroud)

但是,当脚本运行时,我收到以下错误:

使用“3”个参数调用“Write”的异常:“流太长。” 在 C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:809 char:29
+ ... $destStream.Write($buffer, 0, $numberOfBytesRead )
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+fullyQualifiedErrorId : IOException

有什么建议?

compression powershell

5
推荐指数
1
解决办法
9146
查看次数