0

有没有人尝试过使用pkgwith featherjs?我很难让它工作。

运行可执行文件时出现以下错误:

WARNING: No configurations found in configuration directory:/../project/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
pkg/prelude/bootstrap.js:1172
      throw error;
      ^

TypeError: root path required
    at Function.serveStatic [as static] (/snapshot/../project/node_modules/serve-static/index.js:40:11)

如果有人有任何指导,不知道从哪里开始。

"bin": "src/index.js",
"scripts": {
  "test": "npm run eslint && npm run mocha",
  "dev": "./node_modules/nodemon/bin/nodemon.js src/",
  "eslint": "eslint src/. test/. --config .eslintrc.json",
  "mocha": "mocha test/ --recursive --exit",
  "start": "node src/",
  "pkg": "pkg . -t node9-macos-x64 --out-path pkg"
},
"pkg": {
  "assets": [
    "src/**/*",
    "public/**/*",
    "config/**/*",
    "node_modules/config/**/*.*"
  ],
  "scripts": [
    "src/**/*.js",
    "config/**/*.json"
  ]
},
4

1 回答 1

0

该错误来自@feathersjs/configuration使用的节点配置,它试图从正在运行的应用程序的文件夹中加载,而不是从捆绑的包中加载。您可以尝试将NODE_CONFIG环境变量设置为内容或删除以及应用程序所需的配置选项,例如通过要求(这也应该在打包环境中工作):config/default.jsonconfig/defualt.jsonapp.configure(configuration())app.setconfig/default.json

const config = require('../config/default.json');

Object.keys(config).forEach(key => {
  app.set(key, config[key]);
});
于 2018-08-30T22:34:28.350 回答