如何通过 firebase 托管在 firebase 上托管 node.js 网络应用程序(包含多个文件夹)?
how to host node.js web app(containing multiple folders) on firebase through firebase hosting?
我已经完成了所有的 firebase 托管过程。在我的 firebase 帐户中,我可以使用实时数据库、firestore、托管和功能。当我试图在 firebase 上部署我的网络应用程序时,我收到了这个错误:
=== Deploying to 'remonet-f20c4'...
i deploying database, storage, firestore, functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
npm ERR! missing script: lint
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\H P\AppData\Roaming\npm-cache\_logs19-02-28T11_03_51_407Z-debug.log
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "D:\Mangesh\ReMoNet\functions" run lint ENOENT
at notFoundError (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Emitted 'error' event at:
at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Error: functions predeploy error: Command terminated with non-zero exit code1
**我附上了我的项目文件夹的屏幕截图和 firebase.json 文件:
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix ./functions/ run lint",
"npm --prefix ./functions/ run build"
],
"source": "functions"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage.rules"
}
}
Project Folders view
在firebase.json
中配置为在部署前执行lint
npm-script。
npm --prefix ./functions/ run lint
这会导致以下错误。
npm ERR! missing script: lint
您应该确保 functions
中的 package.json
定义了 lint
脚本。
我已经完成了所有的 firebase 托管过程。在我的 firebase 帐户中,我可以使用实时数据库、firestore、托管和功能。当我试图在 firebase 上部署我的网络应用程序时,我收到了这个错误:
=== Deploying to 'remonet-f20c4'...
i deploying database, storage, firestore, functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
npm ERR! missing script: lint
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\H P\AppData\Roaming\npm-cache\_logs19-02-28T11_03_51_407Z-debug.log
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "D:\Mangesh\ReMoNet\functions" run lint ENOENT
at notFoundError (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Emitted 'error' event at:
at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Error: functions predeploy error: Command terminated with non-zero exit code1
**我附上了我的项目文件夹的屏幕截图和 firebase.json 文件:
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix ./functions/ run lint",
"npm --prefix ./functions/ run build"
],
"source": "functions"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage.rules"
}
}
Project Folders view
在firebase.json
中配置为在部署前执行lint
npm-script。
npm --prefix ./functions/ run lint
这会导致以下错误。
npm ERR! missing script: lint
您应该确保 functions
中的 package.json
定义了 lint
脚本。