0

zeit-pkg is a tool for package nodejs code. zeit-pkg also support require('arangojs'). But zeit-pkg returned error for meet const db = require('@arangodb').db; zeit-pkg returns error.

> Error! TypeError: Cannot read property '0' of null
    at shortFromAlias (/usr/local/lib/node_modules/pkg/lib-es5/walker.js:69:49)
    at Walker._callee5$ (/usr/local/lib/node_modules/pkg/lib-es5/walker.js:894:25)
    at tryCatch (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/usr/local/lib/node_modules/pkg/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/lib/node_modules/pkg/node_modules/babel-runtime/helpers/asyncToGenerator.js:30:13
    at <anonymous>

I want to know what's particular in require('@arangodb').db. It's whether any replacement method exists for writing transaction. Or any other package tools can support require('@arangodb').db;

4

1 回答 1

1

zeit-pkg 将 JavaScript 代码编译成可执行文件,这与 Foxx 不兼容,因为 Foxx 是运行 JavaScript 代码的可执行文件。

如果您想最小化/丑化/修改您的代码,请查看 WebPack,ArangoDB 的这份文档向您展示了如何让 WebPack 与 Foxx 一起使用,因为它将这些库标记为“外部”库,可以跳过处理。

于 2018-07-14T01:08:04.057 回答