繁体   English   中英

错误:加载 firebase.json 时出错:未安装 Bolt,运行 npm install -g firebase-bolt

[英]Error: There was an error loading firebase.json: Bolt not installed, run npm install -g firebase-bolt

操作系统:Windows 10 专业版
节点:6.1.0
净资产管理:3.8.6
Gulp:CLI 版本 3.9.1

因此,firebase-bolt 已使用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)

部署-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); });

to-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" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)", "headers" : [{ "key" : "Access-Control-Allow-Origin", "value" : "*" }] }, { "source" : "**/*.@(jpg|jpeg|gif|png)", "headers" : [{ "key" : "Cache-Control", "value" : "max-age=7200" }] } ], "cleanUrls": true, "trailingSlash": false } }

规则.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 } }

这是一个已知问题:在 Windows #205 上找不到 firebase-bolt

Google 更新 firebase-tools 的解决方案是使用提到的软件包npm install -g oscar-b/firebase-tools

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM