Cannot find module './convertRestQueryParams'

System Information
  • Strapi Version: 3.3.0
  • Operating System: Microsoft Windows
  • Database: Postgres
  • Node Version: 14.15.0
  • NPM Version: 6.14.8
  • Yarn Version:

When I am deploying API in azure webapp, I am getting below error.

Error: Cannot find module ‘./convertRestQueryParams’

below is log
Application has thrown an uncaught exception and is terminated:
Error: Cannot find module ‘./convertRestQueryParams’
Require stack:

  • D:\home\site\wwwroot\node_modules\strapi-utils\lib\index.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\core\app-configuration\config-loader.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\core\app-configuration\index.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\Strapi.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\index.js
  • D:\home\site\wwwroot\server.js
  • D:\Program Files (x86)\iisnode\interceptor.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object. (D:\home\site\wwwroot\node_modules\strapi-utils\lib\index.js:7:32)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

Please help me to fix it.

Can you please attach code for the D:\home\site\wwwroot\node_modules\strapi-utils\lib\index.js file.

@sunnyson

Please find below code

‘use strict’;

/**

  • Export shared utilities
    */

const convertRestQueryParams = require(’./convertRestQueryParams’);
const buildQuery = require(’./buildQuery’);
const parseMultipartData = require(’./parse-multipart’);
const sanitizeEntity = require(’./sanitize-entity’);

module.exports = {
cli: require(’./cli’),
commander: require(’./commander’),
finder: require(’./finder’),
joijson: require(’./joi-json’),
json: require(’./json’),
knex: require(’./knex’),
logger: require(’./logger’),
models: require(’./models’),
policy: require(’./policy’),
regex: require(’./regex’),
templateConfiguration: require(’./templateConfiguration’),
convertRestQueryParams,
buildQuery,
parseMultipartData,
sanitizeEntity,
};

I asume you are using a deprecated version, since convertRestQueryParams.js was a module a long time ago, in alpha version.

So this is not 3.3.0 version as you mentioned in the first post. Please check versions and upgrade to a stable one.

@sunnyson I am attaching packakge.json and package-lock.json. It is showing 3.3.4 version. I am not getting why are you saying it is old version?

{
“name”: “sonuto”,
“private”: true,
“version”: “0.1.0”,
“description”: “A Strapi application”,
“scripts”: {
“develop”: “strapi develop”,
“start”: “strapi start”,
“build”: “strapi build”,
“strapi”: “strapi”
},
“devDependencies”: {},
“dependencies”: {
“knex”: “<0.20.0”,
“pg”: “^8.5.1”,
“sqlite3”: “latest”,
“strapi”: “3.3.4”,
“strapi-admin”: “3.3.4”,
“strapi-connector-bookshelf”: “3.3.4”,
“strapi-plugin-content-manager”: “3.3.4”,
“strapi-plugin-content-type-builder”: “3.3.4”,
“strapi-plugin-documentation”: “^3.3.4”,
“strapi-plugin-email”: “3.3.4”,
“strapi-plugin-graphql”: “^3.3.4”,
“strapi-plugin-upload”: “3.3.4”,
“strapi-plugin-users-permissions”: “3.3.4”,
“strapi-provider-upload-azure-storage”: “^1.1.1”,
“strapi-utils”: “3.3.4”
},
“author”: {
“name”: “A Strapi developer”
},
“strapi”: {
“uuid”: “efbc39e2-dc39-406b-ae02-2c69e73c304a”
},
“engines”: {
“node”: “>=10.16.0 <=14.x.x”,
“npm”: “>=6.0.0”
},
“license”: “MIT”
}

Even when I am checking version, it is showing latest. Please see below screenshot.

Because I remember that it was refactored more than one year ago.
Take a look at the current version of this file:

Also, your files contain modules like joijson/commandar/json, which were removed in 2019. Here is the commit.

Here convertRestQueryParams was removed as a module

As I understand you are using and checking the version of the global installed Strapi, we no longer recommend installing strapi globally, instead use local installed strapi per project.

Can you run inside the project folder: npm run strapi version

I have fixed versions but I am getting new error now

[2020-12-16T22:06:09.954Z] error Error: Cannot find module ‘./lib/encoding’
Require stack:

  • D:\home\site\wwwroot\node_modules\negotiator\index.js
  • D:\home\site\wwwroot\node_modules\accepts\index.js
  • D:\home\site\wwwroot\node_modules\koa\lib\request.js
  • D:\home\site\wwwroot\node_modules\koa\lib\application.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\Strapi.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\index.js
  • D:\home\site\wwwroot\server.js
  • D:\Program Files\iisnode\interceptor.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadModule (D:\home\site\wwwroot\node_modules\negotiator\index.js:108:16)
    at Negotiator.encodings (D:\home\site\wwwroot\node_modules\negotiator\index.js:56:28)
    at Accepts.encoding.Accepts.encodings (D:\home\site\wwwroot\node_modules\accepts\index.js:143:26)
    at Object.acceptsEncodings (D:\home\site\wwwroot\node_modules\koa\lib\request.js:571:24)
    at Object.proto. [as acceptsEncodings] (D:\home\site\wwwroot\node_modules\delegates\index.js:40:31)
    at send (D:\home\site\wwwroot\node_modules\koa-send\index.js:88:11)
    at serve (D:\home\site\wwwroot\node_modules\koa-static\index.js:66:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async serveIndexPage (D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\public\index.js:36:11)
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\parser\index.js:48:23
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\xss\index.js:26:9
    [2020-12-16T22:06:10.048Z] debug GET / (154 ms) 500

Project information

┌────────────────────┬──────────────────────────────────────────────────┐
│ Time │ Wed Dec 16 2020 22:06:10 GMT+0000 (Greenwich Me… │
│ Launched in │ 80027 ms │
│ Environment │ PRODUCTION │
│ Process PID │ 5472 │
│ Version │ 3.3.4 (node v14.15.0) │
│ Edition │ Community │
└────────────────────┴──────────────────────────────────────────────────┘

Actions available

Welcome back!
To manage your project 🚀, go to the administration panel at:
http://localhost:\.\pipe\ca1a098c-8fbb-4753-a3a7-80de5ca58afb/admin

To access the server ⚡️, go to:
http://localhost:\.\pipe\ca1a098c-8fbb-4753-a3a7-80de5ca58afb

[2020-12-16T22:06:10.501Z] error Error: ENOENT: no such file or directory, open ‘D:\home\site\wwwroot\favicon.ico’
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at D:\home\site\wwwroot\node_modules\koa-favicon\index.js:50:28
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:96:15
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:75:17
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responses\index.js:9:15
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at cors (D:\home\site\wwwroot\node_modules@koa\cors\index.js:56:38)
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\logger\index.js:56:17
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responseTime\index.js:17:15
at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
[2020-12-16T22:06:10.517Z] debug GET /favicon.ico (16 ms) 500
[2020-12-16T22:06:16.454Z] error Error: Cannot find module ‘./lib/encoding’
Require stack:

  • D:\home\site\wwwroot\node_modules\negotiator\index.js
  • D:\home\site\wwwroot\node_modules\accepts\index.js
  • D:\home\site\wwwroot\node_modules\koa\lib\request.js
  • D:\home\site\wwwroot\node_modules\koa\lib\application.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\Strapi.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\index.js
  • D:\home\site\wwwroot\server.js
  • D:\Program Files\iisnode\interceptor.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadModule (D:\home\site\wwwroot\node_modules\negotiator\index.js:108:16)
    at Negotiator.encodings (D:\home\site\wwwroot\node_modules\negotiator\index.js:56:28)
    at Accepts.encoding.Accepts.encodings (D:\home\site\wwwroot\node_modules\accepts\index.js:143:26)
    at Object.acceptsEncodings (D:\home\site\wwwroot\node_modules\koa\lib\request.js:571:24)
    at Object.proto. [as acceptsEncodings] (D:\home\site\wwwroot\node_modules\delegates\index.js:40:31)
    at send (D:\home\site\wwwroot\node_modules\koa-send\index.js:88:11)
    at serve (D:\home\site\wwwroot\node_modules\koa-static\index.js:66:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async serveIndexPage (D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\public\index.js:36:11)
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\parser\index.js:48:23
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\xss\index.js:26:9
    [2020-12-16T22:06:16.470Z] debug GET / (31 ms) 500
    [2020-12-16T22:06:16.696Z] error Error: ENOENT: no such file or directory, open ‘D:\home\site\wwwroot\favicon.ico’
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at D:\home\site\wwwroot\node_modules\koa-favicon\index.js:50:28
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:96:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:75:17
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responses\index.js:9:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at cors (D:\home\site\wwwroot\node_modules@koa\cors\index.js:56:38)
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\logger\index.js:56:17
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responseTime\index.js:17:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    [2020-12-16T22:06:16.696Z] debug GET /favicon.ico (0 ms) 500
    [2020-12-16T22:07:04.530Z] error Error: Cannot find module ‘./lib/encoding’
    Require stack:
  • D:\home\site\wwwroot\node_modules\negotiator\index.js
  • D:\home\site\wwwroot\node_modules\accepts\index.js
  • D:\home\site\wwwroot\node_modules\koa\lib\request.js
  • D:\home\site\wwwroot\node_modules\koa\lib\application.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\Strapi.js
  • D:\home\site\wwwroot\node_modules\strapi\lib\index.js
  • D:\home\site\wwwroot\server.js
  • D:\Program Files\iisnode\interceptor.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadModule (D:\home\site\wwwroot\node_modules\negotiator\index.js:108:16)
    at Negotiator.encodings (D:\home\site\wwwroot\node_modules\negotiator\index.js:56:28)
    at Accepts.encoding.Accepts.encodings (D:\home\site\wwwroot\node_modules\accepts\index.js:143:26)
    at Object.acceptsEncodings (D:\home\site\wwwroot\node_modules\koa\lib\request.js:571:24)
    at Object.proto. [as acceptsEncodings] (D:\home\site\wwwroot\node_modules\delegates\index.js:40:31)
    at send (D:\home\site\wwwroot\node_modules\koa-send\index.js:88:11)
    at serve (D:\home\site\wwwroot\node_modules\koa-static\index.js:66:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async serveIndexPage (D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\public\index.js:36:11)
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\parser\index.js:48:23
    at async D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\xss\index.js:26:9
    [2020-12-16T22:07:04.548Z] debug GET / (18 ms) 500
    [2020-12-16T22:07:05.008Z] error Error: ENOENT: no such file or directory, open ‘D:\home\site\wwwroot\favicon.ico’
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at D:\home\site\wwwroot\node_modules\koa-favicon\index.js:50:28
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:96:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\boom\index.js:75:17
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responses\index.js:9:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at cors (D:\home\site\wwwroot\node_modules@koa\cors\index.js:56:38)
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\logger\index.js:56:17
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    at D:\home\site\wwwroot\node_modules\strapi\lib\middlewares\responseTime\index.js:17:15
    at dispatch (D:\home\site\wwwroot\node_modules\koa-compose\index.js:42:32)
    [2020-12-16T22:07:05.008Z] debug GET /favicon.ico (0 ms) 500

@sunnyson can you please guide me what may be the issue?

Can you check this folder D:\home\site\wwwroot\node_modules\negotiator\lib, what files do you see there?

@sunnyson it is showing below files

Very strange, so that error says that Cannot find module ‘./lib/encoding’ it doesn’t exist in /negotiator.

How exactly you created this strapi project?

@sunnyson I created this project using below command:

npx create-strapi-app my-project --quickstart

Can you create another project by adding @latest flag:
npx create-strapi-app@latest my-project --quickstart