"SyntaxError: Unexpected token ' in JSON at position 0" when requiring a module using strict mode

"SyntaxError: Unexpected token ' in JSON at position 0" when requiring a module using strict mode

index.js我有

'use strict';

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

config.js我有

'use strict';

const config = new function() {
  this.port = 3000;
  this.redirectUri = "http://localhost:" + this.port + "/auth";
}

module.exports = config;

在 x64 Windows 运行 节点 v6.9.5 上运行良好。

在 Raspberry Pi 零(Raspbian 像素,ARM v6)运行 节点 6.10.2 但是,我收到以下错误:

module.js:590
    throw err;
    ^

SyntaxError: /home/pi/pihas-api/config.json: Unexpected token ' in JSON at position 0
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:587:27)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/pi/pihas-api/index.js:8:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

我知道这是因为我在 config.js 中使用 'use strict';,但我想知道为什么它 对 Windows 有效],以及是否有办法让它在 Pi Zero 上也能正常工作。

JSON 不是 Javascript。你不能在 JSON.

"use strict";