gpt4 book ai didi

javascript - 错误 : There was an error loading firebase. json : Bolt not installed, 运行 npm install -g firebase-bolt

转载 作者:太空宇宙 更新时间:2023-11-04 00:34:57 25 4
gpt4 key购买 nike

操作系统:Windows 10 专业版
Node :6.1.0
NPM: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 }
}

最佳答案

这是一个已知问题:firebase-bolt not found on Windows #205

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

关于javascript - 错误 : There was an error loading firebase. json : Bolt not installed, 运行 npm install -g firebase-bolt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39479973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com