错误:加载firebase时出错.如果没有安装,请执行npm install -g firebase-bolt
Error: There was an error loading firebase.json: Bolt not installed, run npm install -g firebase-bolt
操作系统:Windows 10 Pro
节点:6.1.0
NPM: 3.8.6
Gulp: CLI version 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)
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);
});
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
}
}
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 }
}
这是一个已知的问题:在Windows #205上没有找到firebase-bolt
当Google更新firebase-tools时,解决方案是使用上面提到的软件包npm install -g oscar-b/firebase-tools
相关文章:
- 无法在通过jQuery的ajax加载的页面中执行javascript
- 可以前端maven插件使用节点,npm已经安装
- JavaScript执行暂时挂起页面
- 如何在ReactJS JSX中执行嵌套的if-else语句
- 当js函数's已执行
- 哪个先执行
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- HTML表单提交时未执行外部函数
- 在Safari执行javascript之前对其进行修改
- 全局安装的NodeJS npm模块不执行节点的主/bin JavaScript文件
- npm异步模块未执行最终回调
- 有没有办法运行“;nvm使用“;在启动前npm脚本中自动执行
- 在执行npm时自动添加程序包
- 不是'使用webpack在npm上执行t
- 执行npm start失败
- 错误:加载firebase时出错.如果没有安装,请执行npm install -g firebase-bolt
- 如何创建一个npm命令,在控制台中执行两个命令(一个接一个)
- 编写一个脚本来自动执行npm命令
- watchify在尝试执行npm运行监视时出错
- 使用grunt自动执行npm和安装