Loopback(新手) 报错(Unhandled error for request GET /explorer: Error: Cannot GET /explorer)

按照Loopback文档创建的第一个simpleAPI就没成功,http://0.0.0.0:3000打开显示正常,但http://0.0.0.0:3000/explorer报错如下:

Error

404Cannot GET /explorer

status: 404

Error: Cannot GET /explorer

    at raiseUrlNotFoundError (/Users/loopback-getting-started/node_modules/loopback/server/middleware/url-not-found.js:20:17)

    at Layer.handle [as handle_request] (/Users/loopback-getting-started/node_modules/express/lib/router/layer.js:95:5)

    at trim_prefix (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:317:13)

    at /Users/loopback-getting-started/node_modules/express/lib/router/index.js:284:7

    at Function.process_params (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:335:12)

    at next (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:275:10)

    at /Users/loopback-getting-started/node_modules/express/lib/router/index.js:635:15

    at next (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:260:14)

    at Function.handle (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:174:3)

    at router (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:47:12)

    at Layer.handle [as handle_request] (/Users/loopback-getting-started/node_modules/express/lib/router/layer.js:95:5)

    at trim_prefix (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:317:13)

    at /Users/loopback-getting-started/node_modules/express/lib/router/index.js:284:7

    at Function.process_params (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:335:12)

    at next (/Users/loopback-getting-started/node_modules/express/lib/router/index.js:275:10)

    at nosniff (/Users/loopback-getting-started/node_modules/dont-sniff-mimetype/index.js:4:5)


解决方法:

创建server/component-config.json文件,添加内容:

{

"loopback-component-explorer": {

"mountPath":"/explorer"

    }

}

没有loopback-component-explorer module的

 npm install loopback-component-explorer

自行手动install

再次npm start

http://0.0.0.0:3000/explorer出现API

你可能感兴趣的:(Loopback(新手) 报错(Unhandled error for request GET /explorer: Error: Cannot GET /explorer))