JSPM Error on any 'jspm' command: TypeError: Cannot read property 'startsWith' of undefined

JSPM Error on any 'jspm' command: TypeError: Cannot read property 'startsWith' of undefined

通过NPM成功安装JSPM后;

npm install -g jspm

任何尝试在命令行上 运行 'jspm' 或 'jspm SOMECOMMAND' 都会导致相同的错误:

C:\some\path> jspm

C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\common.js:108
    if (pjson.startsWith('\uFEFF'))

TypeError: Cannot read property 'startsWith' of undefined
    at exports.readJSONSync (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\common.js:108:12)
    at Object.<anonymous> (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\global-config.js:53:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    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> (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\registry.js:19:20)

或(另一个例子):

C:\some\path> jspm registry config github

C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\common.js:108
    if (pjson.startsWith('\uFEFF'))

TypeError: Cannot read property 'startsWith' of undefined
    at exports.readJSONSync (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\common.js:108:12)
    at Object.<anonymous> (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\global-config.js:53:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    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> (C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jspm\lib\registry.js:19:20)

这是 Node.js 的全新安装。版本:

    C:\some\path> node -v
    v6.9.1

    C:\some\path> npm -v
    3.10.9

编辑:

在“..\AppData\Roaming\npm\node_modules\jspm\lib\common.js”中,如果我更改第100行:

var pjson;

var pjson = null;

它改变了错误:

TypeError: Cannot read property 'startsWith' of undefined 

TypeError: Cannot read property 'startsWith' of null 

这是否意味着此 try 块(起始行 101)内的赋值失败并且 'pjson' 没有被赋值?

try {
    pjson = fs.readFileSync(file).toString();
}

此问题已在此处解决:

https://github.com/jspm/jspm-cli/issues/2148

问题是我的 LOCALAPPDATA 环境变量是空的。为了解决这个问题,我将变量设置为 AppData 文件夹的绝对路径。

即C:\Users\username\AppData\Local