【问题标题】:failing to launch node app config file无法启动节点应用程序配置文件
【发布时间】:2017-04-18 09:42:50
【问题描述】:

我对 nodeJs 完全陌生。我在用 node 5.0.0 克隆了一个 repo 并启动了命令:

node ./app.js -c config.yaml

但我收到此错误

node_modules/q/q.js:155
                throw e;
            ^

SyntaxError: Unexpected token u
    at Object.parse (native)
    at yaml2json (/home/../mosaic-techonmap-server/source/config.access.js:13:21)
    at module.exports (/home/../mosaic-techonmap-server/source/config.access.js:152:23)
    at /home/../app.js:89:45
    at _fulfilled (/home/../node_modules/q/q.js:854:54)
    at self.promiseDispatch.done (/home/../mosaic-techonmap-server/node_modules/q/q.js:883:30)
    at Promise.promise.promiseDispatch (/home/../mosaic-techonmap-server/node_modules/q/q.js:816:13)
    at /home/../mosaic-techonmap-server/node_modules/q/q.js:877:14
    at runSingle (/home/../mosaic-techonmap-server/node_modules/q/q.js:137:13)
    at flush (/home/../mosaic-techonmap-server/node_modules/q/q.js:125:13)

有人有想法吗?

编辑:这是config.yaml 文件的代码

---
# Configuration sample file for Jingo (YAML)
application:
    title: "CartoWiki"
server:
    hostname: "localhost"
    port: 6067
    localOnly: false
    baseUrl: "http://localhost:6067"
authentication:
    google:
      enabled: true
    twitter:
      enabled: true
      oauthkeys:
        consumerKey : ''
        consumerSecret : ''
      cacheExpire: 3600000
    facebook:
      enabled: true
      oauthkeys:
        clientID : ''
        clientSecret : ''
    alone:
      enabled: false
      username: ""
      passwordHash: ""
      email: ""
twitterClient:
    consumerKey : ''
    consumerSecret : ''
    accessTokenKey : ''
    accessTokenSecret : ''

【问题讨论】:

  • 你之前跑过npm install吗?
  • 不能在作者的github上创建issue吗?
  • 也发布config.yaml代码
  • @KarthikeyanVaithilingam 我刚刚发布了配置文件
  • 是的@AndreiNemes 是的我跑了npm install

标签: javascript node.js config


【解决方案1】:

我克隆了 repo,当我尝试您的 config.yaml 时,我能够重现该问题。

config.access.js:152:23 中,config.accessRules 除外,但您的 yaml 文件没有accessRules,因此accessRules 对象由于错误Unexpected token u 而变得未定义

accessRules 添加到您的配置中,那么您应该不会收到此错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-21
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 2015-04-03
    • 1970-01-01
    • 2018-08-20
    • 2022-01-11
    相关资源
    最近更新 更多