我使用express框架开发了一个简单的node js登录应用程序。这是我的文件结构:
当我尝试运行“ npm start”时,它显示:
internal/modules/cjs/loader.js:631
throw new ERR_INVALID_ARG_TYPE('id', 'string', id);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type
string. Received type object
什么原因导致此错误?我该怎么解决?
这是错误堆栈:
13 verbose stack Error: nodeauth@0.0.0 start: `node ./bin/www`
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
at Module.require (internal/modules/cjs/loader.js:631:11)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/jiatongli/Desktop/nodeauth/app.js:13:14)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
答案 0 :(得分:0)
如果您声明了无单引号的var express = require(express),可能是您收到此错误。修改var express = require('express');而不是var express = require(express);