2016-09-13 2 views
1

ОС: Windows 10 Pro
Node: 6.1.0
НПМ: 3.8.6
Глоток: CLI версия 3.9.1Ошибка: Существовал ошибка загрузки firebase.json: Болт не установлен, запустите НПМ установки -g firebase болт

Таким образом, болт с молнией был установлен по всему миру с использованием, npm install -g firebase-bolt. Но я получаю следующее сообщение об ошибке при запуске процесса сборки:

Error: There was an error loading firebase.json: 
 

 
Bolt not installed, run npm install -g firebase-bolt 
 
[21:47:04] 'deploy-firebase' errored after 8.29 s 
 
[21:47:04] Error: 1 
 
    at formatError (C:\Users\d0475\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:169:10) 
 
    at Gulp.<anonymous> (C:\Users\d0475\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:195:15) 
 
    at emitOne (events.js:101:20) 
 
    at Gulp.emit (events.js:188:7) 
 
    at Gulp.Orchestrator._emitTaskDone (C:\Users\d0475\Documents\Projects\esteMasterApp2\node_modules\orchestrator\index.js:264:8) 
 
    at C:\Users\d0475\Documents\Projects\esteMasterApp2\node_modules\orchestrator\index.js:275:23 
 
    at finish (C:\Users\d0475\Documents\Projects\esteMasterApp2\node_modules\orchestrator\lib\runTask.js:21:8) 
 
    at ChildProcess.cb (C:\Users\d0475\Documents\Projects\esteMasterApp2\node_modules\orchestrator\lib\runTask.js:29:3) 
 
    at emitTwo (events.js:106:13) 
 
    at ChildProcess.emit (events.js:191:7) 
 
    at ChildProcess.cp.emit (C:\Users\d0475\Documents\Projects\esteMasterApp2\node_modules\cross-spawn\lib\enoent.js:40:29) 
 
    at maybeClose (internal/child_process.js:850:16) 
 
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

Deploy-firebase.js

import spawn from 'cross-spawn'; 
 
import gulp from 'gulp'; 
 

 
gulp.task('deploy-firebase', ['to-html'], done => { 
 
    // childProcess 
 
    spawn('firebase', ['deploy'], { stdio: 'inherit' }) 
 
    .on('close', done); 
 
});

к html.js

const urls = { 
 
    '/': 'index.html', 
 
    '/404': '404.html', 
 
}; 
 

 
gulp.task('to-html', done => { 
 
    args.production = true; 
 
    process.env.IS_SERVERLESS = true; 
 

 
    const fetch = url => new Promise((resolve, reject) => { 
 
    http.get({ host: 'localhost', path: url, port: 3000 }, res => { 
 
     // Explicitly treat incoming data as utf8 (avoids issues with multi-byte). 
 
     res.setEncoding('utf8'); 
 
     let body = ''; 
 
     res.on('data', data => { 
 
     body += data; 
 
     }); 
 
     res.on('end',() => resolve(body)); 
 
    }).on('error', reject); 
 
    }); 
 

 
    const moveAssets =() => { 
 
    const assets = fs.readdirSync('build'); 
 
    fs.mkdirSync(path.join('build', 'assets')); 
 
    assets.forEach(fileName => { 
 
     fs.renameSync(
 
     path.join('build', fileName), 
 
     path.join('build', 'assets', fileName) 
 
    ); 
 
    }); 
 
    }; 
 

 
    const toHtml =() => { 
 
    const promises = Object.keys(urls).map(url => fetch(url).then(html => { 
 
     fs.writeFile(path.join('build', urls[url]), html); 
 
    })); 
 
    return Promise.all(promises); 
 
    }; 
 

 
    runSequence('eslint-ci', 'ava', 'flow', 'clean', 'build',() => { 
 
    const proc = spawn('node', ['./src/server']); 
 
    proc.stderr.on('data', data => console.log(data.toString())); 
 
    proc.stdout.on('data', async data => { 
 
     data = data.toString(); 
 
     if (data.indexOf('Server started') === -1) return; 
 
     try { 
 
     moveAssets(); 
 
     await toHtml(); 
 
     } catch (error) { 
 
     console.log(error); 
 
     } finally { 
 
     proc.kill(); 
 
     done(); 
 
     console.log('App has been rendered to /build directory.'); 
 
     console.log('OSX tip: cd build && python -m SimpleHTTPServer 3000'); 
 
     } 
 
    }); 
 
    }); 
 
});

firebase.json

{ 
 
    "database": { 
 
    "rules": "./firebase/rules.bolt" 
 
    }, 
 
    "hosting": { 
 
    "public": "build", 
 
    "rewrites": [ 
 
     { 
 
     "source": "**", 
 
     "destination": "/index.html" 
 
     } 
 
    ], 
 
    "headers": [ 
 
     { 
 
     "source" : "**/*[email protected](eot|otf|ttf|ttc|woff|font.css)", 
 
     "headers" : [{ 
 
      "key" : "Access-Control-Allow-Origin", 
 
      "value" : "*" 
 
     }] 
 
     }, { 
 
     "source" : "**/*[email protected](jpg|jpeg|gif|png)", 
 
     "headers" : [{ 
 
      "key" : "Cache-Control", 
 
      "value" : "max-age=7200" 
 
     }] 
 
     } 
 
    ], 
 
    "cleanUrls": true, 
 
    "trailingSlash": false 
 
    } 
 
}

rules.bolt

// An example of Firebase security and modeling language. 
 
// https://github.com/firebase/bolt/blob/master/docs/guide.md 
 

 
// Functions 
 

 
isSignedIn() { auth != null } 
 
isViewer(uid) { isSignedIn() && auth.uid == uid } 
 
isFriend(uid) { true } // We can limit access to sensitive data easily. 
 

 
// Types 
 

 
// github.com/firebase/bolt/blob/master/docs/guide.md#dealing-with-timestamps 
 
type CurrentTimestamp extends Number { 
 
    validate() { this == now } 
 
} 
 

 
type ShortString extends String { 
 
    validate() { this.length <= 100 } 
 
} 
 

 
type ShortRequiredString extends String { 
 
    // Required form field with maxLength="100". 
 
    validate() { this.length > 0 && this.length <= 100 } 
 
} 
 

 
type LongString extends String { 
 
    validate() { this.length <= 1000 } 
 
} 
 

 
type LongRequiredString extends String { 
 
    validate() { this.length > 0 && this.length <= 1000 } 
 
} 
 

 
type ExtraLongString extends String { 
 
    validate() { this.length <= 10000 } 
 
} 
 

 
type ExtraLongRequiredString extends String { 
 
    validate() { this.length > 0 && this.length <= 10000 } 
 
} 
 

 
type HelloWorld { 
 
    createdAt: CurrentTimestamp, 
 
    text: ShortString 
 
} 
 

 
type User { 
 
    displayName: LongString, 
 
    id: ShortRequiredString, 
 
    photoURL: LongString, 
 
    validate() { this.id == auth.uid } 
 
} 
 

 
type UserEmail { 
 
    email: ShortRequiredString 
 
} 
 

 
type UserPresence { 
 
    authenticatedAt: CurrentTimestamp, 
 
    user: User 
 
} 
 

 
// Paths 
 

 
path /hello-world is HelloWorld { 
 
    // Anyone can create, read, update. No one can delete. 
 
    create() { true } 
 
    read() { true } 
 
    update() { true } 
 
} 
 

 
path /users/{uid} is User { 
 
    read() { isFriend(uid) } 
 
    write() { isViewer(uid) } 
 
} 
 

 
path /users-emails/{uid} is UserEmail { 
 
    read() { isViewer(uid) } 
 
    write() { isViewer(uid) } 
 
} 
 

 
path /users-presence { 
 
    read() { true } // Sure we can limit access here as well. 
 
} 
 

 
path /users-presence/{uid} is UserPresence[] { 
 
    create() { isViewer(uid) } 
 
    update() { true } 
 
    delete() { true } 
 
}

ответ

1

Это известная проблема: firebase-bolt not found on Windows #205

Решение, в то время как обновление Google firebase-инструментов, является использование пакета, указанного, npm install -g oscar-b/firebase-tools