Getting an error -[ERR_INVALID_ARG_TYPE]: The "path" argument

Hi,

Trying to NPM install. I am getting following error. “error The “path” argument must be of type string or an instance of Buffer or URL. Received null”

Anybody why this is happening?
559 timing auditReport:getReport Completed in 738ms
560 silly audit report {}
561 timing auditReport:init Completed in 0ms
562 timing reify:audit Completed in 739ms
563 timing reify:trash Completed in 996ms
564 timing command:install Completed in 6192ms
565 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string or an instance of Buffer or URL. Received null
565 verbose stack at open (node:fs:551:10)
565 verbose stack at go$open (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:357:14)
565 verbose stack at Object.open (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:354:12)
565 verbose stack at writeFile (node:fs:2169:6)
565 verbose stack at go$writeFile (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:138:14)
565 verbose stack at writeFile (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:135:12)
565 verbose stack at node:internal/util:364:7
565 verbose stack at new Promise ()
565 verbose stack at writeFile (node:internal/util:350:12)
565 verbose stack at Shrinkwrap.save (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js:1140:7)
566 verbose cwd /home/maghof/strapi/strapdock
567 verbose Linux 5.10.0-19-amd64
568 verbose node v16.19.1
569 verbose npm v8.19.3
570 error code ERR_INVALID_ARG_TYPE
571 error The “path” argument must be of type string or an instance of Buffer or URL. Received null
572 verbose exit 1
573 timing npm Completed in 6303ms
574 verbose unfinished npm timer reify 1679918127877
575 verbose unfinished npm timer reify:save 1679918133820
576 verbose code 1
577 error A complete log of this run can be found in:
577 error /root/.npm/_logs/2023-03-27T11_55_27_768Z-debug-0.log

/M

What version of npm and node are you using.
Also what is the command you are trying to run.

Trying to do an “NPM Install”.

NPM 8.19.3
NODEJS 16.19.1

/M

Could you please try remove package-lock.json / yarn.lock also node_modules and then do npm install again ? :slight_smile:

Thanks E! It solved that issue.

/M

1 Like

Glad you got it resolved.

Same problem here

  • removed package-lock.json
  • removed node_modules
    → Still same error :see_no_evil:
    I’m on Node v18.16.1 and npm 9.5.1

Any advice anyone?

Thanks!
Will

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ │
│ TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined │
│ at __node_internal_captureLargerStackTrace (node:internal/errors:496:5) │
│ at new NodeError (node:internal/errors:405:5) │
│ at validateString (node:internal/validators:162:11) │
│ at Object.join (node:path:429:7) │
│ at D:\Backend\strapi\node_modules@strapi\core\dist\loaders\components.js:17:31 │
│ at Array.forEach () │
│ at D:\Backend\strapi\node_modules@strapi\core\dist\loaders\components.js:14:32 │
│ at Array.reduce () │
│ at loadComponents (D:\Backend\strapi\node_modules@strapi\core\dist\loaders\components.js:13:39) │
│ at async Promise.all (index 5) │
│ at async Module.loadApplicationContext (D:\Backend\strapi\node_modules@strapi\core\dist\loaders\index.js:12:3) │
│ at async Object.register (D:\Backend\strapi\node_modules@strapi\core\dist\providers\registries.js:26:5) │
│ at async Strapi.register (D:\Backend\strapi\node_modules@strapi\core\dist\Strapi.js:322:7) │
│ at async Strapi.load (D:\Backend\strapi\node_modules@strapi\core\dist\Strapi.js:314:5) │
│ at async Module.develop (D:\Backend\strapi\node_modules@strapi\strapi\dist\node\develop.js:177:28) │
│ at async action (D:\Backend\strapi\node_modules@strapi\strapi\dist\cli\commands\develop.js:18:5) │
│ at async Command.parseAsync (D:\Backend\strapi\node_modules\commander\lib\command.js:923:5) │
│ at async runCLI (D:\Backend\strapi\node_modules@strapi\strapi\dist\cli\index.js:75:3) │
│ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

pls fix this solution

This might help someone. I encountered an issue where an empty yarn.lock folder was being created during development builds, even though I’m using npm. Deleting this folder resolved the error for me.

1 Like

Getting same error can anyone fix this

i don’t have any yarn.lock folder what i need to do now

Hey, thanks! This fixed it for me. The docker-compose.yml file provided from here creates a yarn.lock file which breaks everything when using just npm.

Hi.
I get this issue especially when I am creating a component. I create a component, add a field, and save it, the server restarts and when starting Strapi, it’s throwing this error. When I create a collection type or a single type, it works fine. Only when I create a component, I get this error. Although, it creates the respective files in the src/components directory. When I delete the created component from that directory and restart the server, it starts fine again. Here’s the component’s JSON file:

// src/components/shared/link.json

{
  "collectionName": "components_shared_links",
  "info": {
    "displayName": "Link",
    "icon": "link"
  },
  "options": {},
  "attributes": {
    "href": {
      "type": "string"
    }
  }
}

Yarn version: v1.22.9
Database: mysql
Node version: 18.20.3
NPM version: 10.2.5

I have tested this with the latest version of Strapi (v4.25.3) and I am able to reproduce this issue. With a relatively older version (v4.13.5), this does not happen. I am able to create components in a Strapi application bootstrapped with v4.13.5. But when I do it with a Strapi application bootstrapped with v4.25.3, I get the error.

A possible fix for time-being until this issue is fixed could be to downgrade the Strapi version.

I’m with the same problem. When I create the first Component, the application has crashed.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined  
1 Like

I am still facing the same problem. Please is there any update on this yet?

it’s working now. I upgrade the strapi version to version 4.25.4

1 Like