错误“声明(argc)==(4)'失败”是什么意思?

时间:2019-11-24 23:13:25

标签: node.js reactjs npm

我正在尝试做React in Action图书项目,以了解React。但是我在接下来的步骤中停止执行命令npm run db:seed。我在下面遇到以下错误。我还将在Github上保留项目链接:https://github.com/react-in-action/letters-social

一种信息是我正在尝试的那本书的摘录。

  

为避免您必须运行MongoDB或PostgreSQL之类的数据库,我们将通过JSONserver库(https://github.com/typicode/jsonserver)使用模拟的REST API。我对默认服务器(可以在存储库的db文件夹中看到)进行了一些修改,这些修改使项目变得更简单了。您将获得一个轻量级数据库,该数据库可以通过读取和修改JSON文件来使用,而不是使用数据库。要创建样本数据或重置您的应用程序数据,您可以运行以下命令:npm run db:seed

这是显示的错误:

    letters-social@1.0.0 db:seed E:\Users\Home\myProjects\letters-social
node -r @std/esm db/seed.js

npm[10144]: c:\ws\src\node_file.cc:836: Assertion (argc) == (4)' failed.
 1: 00007FF7E5D1124F napi_wrap+124431
 2: 00007FF7E5CB2A06 v8::base::CPU::has_sse+34502
 3: 00007FF7E5CB2D23 v8::base::CPU::has_sse+35299
 4: 00007FF7E5CB063D v8::base::CPU::has_sse+25341
 5: 00007FF7E646C4E0 v8::internal::Builtins::builtin_handle+325536
 6: 00007FF7E646BA27 v8::internal::Builtins::builtin_handle+322791
 7: 00007FF7E646BD68 v8::internal::Builtins::builtin_handle+323624
 8: 00007FF7E646BB6E v8::internal::Builtins::builtin_handle+323118
 9: 00007FF7E68E414D v8::internal::SetupIsolateDelegate::SetupHeap+568205
10: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
11: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
12: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
13: 00007FF7E685CF8C v8::internal::SetupIsolateDelegate::SetupHeap+14796
14: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
15: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
16: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
17: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
18: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
19: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
20: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
21: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
22: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
23: 00007FF7E685CF8C v8::internal::SetupIsolateDelegate::SetupHeap+14796
24: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
25: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
26: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
27: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
28: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
29: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
30: 00007FF7E6863BDC v8::internal::SetupIsolateDelegate::SetupHeap+42524
31: 00007FF7E6861191 v8::internal::SetupIsolateDelegate::SetupHeap+31697
32: 00007FF7E6860D7C v8::internal::SetupIsolateDelegate::SetupHeap+30652
33: 00007FF7E63C62D3 v8::internal::Execution::CallWasm+1395
34: 00007FF7E63C5C56 v8::internal::Execution::Call+182
35: 00007FF7E6496ECB v8::Function::Call+603
36: 00007FF7E5CD9DDE node::Start+1150
37: 00007FF7E5CDA087 node::Start+1831
38: 00007FF7E5CD8F5A node::LoadEnvironment+26
39: 00007FF7E5C7BA95 v8::internal::Scope::locals+30565
40: 00007FF7E5CD9A73 node::Start+275
41: 00007FF7E5B9667C RC4_options+339324
42: 00007FF7E6997138 v8::internal::SetupIsolateDelegate::SetupHeap+1301368
43: 00007FFA9A187974 BaseThreadInitThunk+20
44: 00007FFA9AB0A271 RtlUserThreadStart+33
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! letters-social@1.0.0 db:seed: `node -r @std/esm db/seed.js`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the letters-social@1.0.0 db:seed script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\Users\Home\AppData\Roaming\npm-cache\_logs\2019-11-24T17_09_37_232Z-debug.log

E:\Users\Home\myProjects\letters-social>npm i db:seed
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "db:": db:seed

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\Users\Home\AppData\Roaming\npm-cache\_logs\2019-11-24T17_43_34_307Z-debug.log

这是运行npm run start时运行应用程序时浏览器的外观

这是服务启动时的日志:

 letters-social@1.0.0 start E:\Users\Home\myProjects\letters-social
> cross-env NODE_ENV=production pm2 start ./index.js --no-daemon

pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
[2019-11-24 13:52:17] PM2 log: Launching in no daemon mode
[2019-11-24 13:52:17] PM2 log: [PM2] Starting E:\Users\Home\myProjects\letters-social\index.js in fork_mode (1 instance)
[2019-11-24 13:52:17] PM2 log: Starting execution sequence in -fork mode- for app name:index id:0
[2019-11-24 13:52:17] PM2 log: App name:index id:0 online
[2019-11-24 13:52:17] PM2 log: [PM2] Done.
[2019-11-24 13:52:19] PM2 log: 
┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ index    │ 0  │ fork │ 1260 │ online │ 0       │ 1s     │ 0%  │ 20.7 MB   │ Home │ disabled │
└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
[2019-11-24 13:52:19] PM2 log:  Use `pm2 show <id|name>` to get more details about an app
[2019-11-24 13:52:19] PM2 log: [--no-daemon] Continue to stream logs
[2019-11-24 13:52:19] PM2 log: [--no-daemon] Exit on target PM2 exit pid=2660
13:52:51 0|index    | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
13:52:51 0|index    | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
13:52:53 0|index    | ==> �  Newsfeed is running on port 3000 ✅
14:03:49 0|index    | ::1 - - [24/Nov/2019:17:03:49 +0000] "GET / HTTP/1.1" 404 136 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
14:03:50 0|index    | Error: Not found
14:03:50 0|index    |     at E:/Users/Home/myProjects/letters-social/server/server.js:43:17
14:03:50 0|index    |     at Layer.handle [as handle_request] (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\layer.js:95:5)
14:03:50 0|index    |     at trim_prefix (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:317:13)
14:03:50 0|index    |     at E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:284:7
14:03:50 0|index    |     at Function.process_params (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:335:12)
14:03:50 0|index    |     at next (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:275:10)
14:03:50 0|index    |     at favicon (E:\Users\Home\myProjects\letters-social\node_modules\serve-favicon\index.js:68:7)
14:03:50 0|index    |     at Layer.handle [as handle_request] (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\layer.js:95:5)
14:03:50 0|index    |     at trim_prefix (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:317:13)
14:03:50 0|index    |     at E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:284:7
14:31:23 0|index    | ::1 - - [24/Nov/2019:17:31:23 +0000] "GET / HTTP/1.1" 404 136 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
14:31:23 0|index    | Error: Not found
14:31:23 0|index    |     at E:/Users/Home/myProjects/letters-social/server/server.js:43:17
14:31:23 0|index    |     at Layer.handle [as handle_request] (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\layer.js:95:5)
14:31:24 0|index    |     at trim_prefix (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:317:13)
14:31:24 0|index    |     at E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:284:7
14:31:24 0|index    |     at Function.process_params (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:335:12)
14:31:24 0|index    |     at next (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:275:10)
14:31:24 0|index    |     at favicon (E:\Users\Home\myProjects\letters-social\node_modules\serve-favicon\index.js:68:7)
14:31:24 0|index    |     at Layer.handle [as handle_request] (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\layer.js:95:5)
14:31:24 0|index    |     at trim_prefix (E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:317:13)
14:31:24 0|index    |     at E:\Users\Home\myProjects\letters-social\node_modules\express\lib\router\index.js:284:7
14:31:25 0|index    | ::1 - - [24/Nov/2019:17:31:25 +0000] "GET /favicon.ico HTTP/1.1" 200 - "http://localhost:3000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"

这是我的页面开始启动项目的方式:

Erro: Not Found!

1 个答案:

答案 0 :(得分:0)

错误消息似乎缩小到这两行

npm ERR! code EUNSUPPORTEDPROTOCOL 
npm ERR! Unsupported URL Type "db:": db:seed

指向数据库的URL链接不正确,或者您尚未添加正确的数据库文件。

安装的DB文件是否像文件here一样正确书写?

回答标题中的问题“断言错误”是Visual Studio应用程序格式化错误消息的方式,该错误消息指示JS文件中的参数存在错误。

它在Microsoft文档中声明

  

”断言语句指定您希望成为的条件   在程序中的某个时刻为true。如果该条件不成立,则   断言失败,程序执行被中断,并且   出现断言失败对话框。“

source: docs.microsoft.com

因此很可能导致连接数据库的断言语句参数不正确。