我正在尝试使用 lambda 上传 node_modules 但我得到了"Cannot find module"
error.
我已经设置了一个真正简单的 hello world js 文件
var async = require('async');
我已经手动复制了node_modules/async
文件夹到发行版中 - 我将 node_modules 文件夹与 hello world js 文件一起复制。
我用我的照片缩放器 lambda 做了一个非常类似的事情,它也采用节点模块并且有效。我做错了什么有什么不同?
zip 文件的结构很重要。假设我有一个 javascript 函数包含在一个名为foo.js
依赖于其他节点模块。
在我的开发环境中,我会有这样的结构:
devdir/
foo/
foo.js
node_modules/
<the nodejs modules>
然后我创建一个名为的 zip 文件foo.zip
结构如下:
$ unzip -vl foo.zip
Archive: foo.zip
Length Method Size Ratio Date Time CRC-32 Name
------- ------ ------- ----- ---- ---- ------ ----
0 Defl:N 0 0% 08-05-15 14:44 00000000 ./
3047 Defl:N 981 68% 08-05-15 14:25 06e3e178 foo.js
0 Defl:N 0 0% 08-03-15 13:37 00000000 node_modules/
0 Defl:N 0 0% 08-03-15 13:37 00000000 node_modules/.bin/
597 Defl:N 301 50% 03-05-15 14:29 9b0c2ba2 node_modules/.bin/uuid
0 Defl:N 0 0% 07-16-15 08:32 00000000 node_modules/async/
3454 Defl:N 1537 56% 06-28-15 18:37 967a5404 node_modules/async/CHANGELOG.md
<...>
确保你的 zip 文件的结构是这样的,应该没问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)