简体   繁体   中英

ArangoDB Foxx Service ReferenceError: URL is not defined

I'm trying to install a service to ArangoDB with the Foxx CLI but I get an error when using joi as a dependency. The full stack trace is below:

Server encountered errors executing a JavaScript file:

@ node_modules/@sideway/address/lib/domain.js:14:21
  12 |     tldSegmentRx: /^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
  13 |     domainSegmentRx: /^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
> 14 |     URL: Url.URL || URL                                                                 // $lab:coverage:ignore$    
     |                     ^
  15 | };
  16 | 
  17 | 
ArangoError 3103: failed to invoke module
File: /tmp/arangod_bepCMN/services-tmp-1-4156953835/node_modules/@sideway/address/lib/domain.js
Reason: ReferenceError: URL is not defined
    at Object.<anonymous> (/tmp/arangod_bepCMN/services-tmp-1-4156953835/node_modules/@sideway/address/lib/domain.js:14:21)
    at Module._compile (/usr/share/arangodb3/js/common/bootstrap/modules.js:606:8)
    at Object.Module._extensions..js (/usr/share/arangodb3/js/common/bootstrap/modules.js:624:12)
    at Module.load (/usr/share/arangodb3/js/common/bootstrap/modules.js:551:36)
    at Function.Module._load (/usr/share/arangodb3/js/common/bootstrap/modules.js:496:16)
    at require (/usr/share/arangodb3/js/common/bootstrap/modules.js:98:21)
    at Object.<anonymous> (/tmp/arangod_bepCMN/services-tmp-1-4156953835/node_modules/joi/lib/types/string.js:4:16)        
    at Module._compile (/usr/share/arangodb3/js/common/bootstrap/modules.js:606:8)
    at Object.Module._extensions..js (/usr/share/arangodb3/js/common/bootstrap/modules.js:624:12)
    at Module.load (/usr/share/arangodb3/js/common/bootstrap/modules.js:551:36)

For details check the arangod server logs.

This issue states that the error might be caused by the ignore file but I'm not using a .foxxignore file at all. Any idea what else could cause this error?

Below is my package.json with all the scripts. The install:service , upgrade:service and setup all throw this error.

{
  "name": "auth",
  "version": "0.0.0",
  "description": "",
  "main": "dist/entry.js",
  "scripts": {
    "build": "tsc -p .",
    "install:service": "npm run build && foxx install /auth --server dev --database party",
    "upgrade:service": "npm run build && foxx upgrade /auth --server dev --database party",
    "setup": "foxx server set dev http://root:password@localhost:8529 --database party && npm run install:service"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "joi": "^17.4.2"
  },
  "devDependencies": {
    "@types/arangodb": "^3.5.13",
    "@types/joi": "^17.2.3",
    "@types/node": "^16.11.6",
    "tslint": "^6.1.3",
    "typescript": "^4.4.4"
  }
}

This might be late, but I've found that the newer versions of joi to be incompatible with the one installed underneath the covers (v14).

Here's what works for me (excerpt from package.json ):

{
    "dependencies": {
        "chai": "^4.3.4",
        "joi": "^14.3.1"
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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