简体   繁体   中英

Receiving cannot find module error, how do I fix it?

const { getIo } = require('services/socketio');
const restful = require('utils/restful');
const publicApiService = require('services/publicApi');
const accessTokenMiddleware = require('middleware/accessToken');
const validateSessionCookieMiddleware = require('middleware/validateSessionCookie');
const logger = require('utils/logger');

package.json:

"scripts": {
        "start": "node ./bin/www",
        ...

}

I get this error:

 internal/modules/cjs/loader.js:796
    throw err;

^

Error: Cannot find module 'services/socketio'

I tried running set NODE_PATH=./lib in terminal but it doesn't fix it.

您的本地模块应以./开头 - 因此将其更改为'./services/publicApi'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM