从安装Persevere的其他文件夹启动它



我使用"npm install persistent example wiki"安装了Perservere,如下所述http://persvr.org/Installation.从文件夹node_modules/persive启动服务器示例wiki确实可以按指定方式工作。这是我请求的服务器日志

$ pwd
PROJECT_ROOT/node_modules/persevere-example-wiki
$ node index.js 
Listening on port 8282
persevere>createContext { id: 'Example',
  content: 'this is a testnn   and some other test',
  createdBy: 'admin',
  status: 'published',
  lastModifiedBy: 'qwe123' }
createContext public not found
error writing [object Object]TypeError: first argument must be a string or Buffer

然而,有几件事我不明白:即使我提供了正确的数据库凭据,也不会在数据库服务器中保存任何东西,我输入到应用程序中的每一个数据都只保存在"node_modules/persistent-example-wiki/data"文件夹中的纯文本JSON文件中。

我如何从不同于node_modules/persistent示例wiki的文件夹开始persistent?我确信有一种方法可以配置路径,我想知道如何配置。我尝试将local.json复制到祖父母文件夹,并尝试从那里开始,但出现了更多错误:

$ node node_modules/persevere-example-wiki/index.js 
fs.js:427
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'data/User'
    at Object.fs.openSync (fs.js:427:18)
    at Object.exports.openSync (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/promised-io/fs.js:154:27)
    at initializeFile (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/perstore/store/memory.js:213:21)
    at store.setPath (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/perstore/store/memory.js:257:3)
    at Object.store.setPath (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/perstore/store/notifying.js:20:4)
    at Object.notifyingStore.setPath (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/perstore/store/replicated.js:16:20)
    at Object.facet.(anonymous function) [as setPath] (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/perstore/facet.js:719:37)
    at Object.security.getUserModel (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/pintura/security.js:88:15)
    at Function.Authentication (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/pintura/jsgi/auth.js:14:11)
    at JsgiApp (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/persevere-example-wiki/node_modules/pintura/pintura.js:58:37)

现在,Persevere框架本身似乎过于复杂——或者可能只是文档问题。无论如何,用一个非常复杂的例子似乎不是一个好主意。一般来说,我更喜欢从较小的例子中进行构建。

使用NODE_PATH环境变量添加PROJECT_ROOT/node_modules/persevere-example-wiki作为默认搜索目录:

   export NODE_PATH=$PROJECT_ROOT/node_modules/persevere-example-wiki

参考

  • Node.js API:从全局文件夹加载

  • Node.js博客:开发环境

  • node.js变更日志

相关内容

  • 没有找到相关文章

最新更新