cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string.

Open wjureczka opened this issue 3 years ago • 16 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

On the local machine packages and workspaces are installed properly.

When using gitlab CI, this error occur:

npm timing reifyNode:node_modules/react-native Completed in 224225ms
npm timing reify:unpack Completed in 224435ms
npm timing command:i Completed in 247734ms
npm verb stack TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
npm verb stack     at new NodeError (node:internal/errors:372:5)
npm verb stack     at validateString (node:internal/validators:120:11)
npm verb stack     at relative (node:path:1191:5)
npm verb stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1073:21
npm verb stack     at Array.map (<anonymous>)
npm verb stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1071:66
npm verb stack     at Array.map (<anonymous>)
npm verb stack     at Arborist.[rollbackMoveBackRetiredUnchanged] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1071:8)
npm verb stack     at Arborist.[reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:235:31)
npm verb stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:155:5)
npm verb cwd /builds/millionpugs/web-frontend
npm verb Linux 5.4.109+
npm verb node v16.15.0
npm verb npm  v8.10.0
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "from" argument must be of type string. Received undefined
npm verb exit 1
npm timing npm Completed in 247884ms

Expected Behavior

It should install without errors or create debug log that helps to find a solution.

Steps To Reproduce

Just run npm i

Environment

  • npm: 8.10.0
  • Node.js: 14.17.4 or 16.15.0
  • OS Name: macOS / GITLAB CI
  • System Model Name: macOs Monterey
  • npm config:
; node bin location = /Users/wjureczka/.nvm/versions/node/16.15.0/bin/node
; node version = v16.15.0
; npm local prefix = /Users/wjureczka/Projects/
; npm version = 8.10.0
; cwd = /Users/wjureczka/Projects/
; HOME = /Users/wjureczka

wjureczka avatar May 17 '22 11:05 wjureczka

I am also facing the same issue. Is there any updte?

mhamzas avatar Jun 12 '22 10:06 mhamzas

I got this error just now when running npm audit fix --legacy-peer-deps. I haven't yet narrowed down which new dependency is triggering this issue.

EDIT: I tried installing some of the recommended dependencies to no avail. The error did not return when I ran npm audit fix --legacy-peer-deps --dry-run. However, deleting package-lock.json and running npm i caused the issue magically to go away. 🤷

AverageHelper avatar Jun 14 '22 22:06 AverageHelper

getting the same error during an npm package installation node v16.15.0 npm v8.10.0

SimRunBot avatar Aug 24 '22 18:08 SimRunBot

I am getting the same error. Has anyone been able to fix it?

umair-mirza avatar Aug 27 '22 09:08 umair-mirza

I used yarn add instead of npm install to install my package (inside CRA project) , that worked, but would not consider the issue fixed

SimRunBot avatar Aug 27 '22 09:08 SimRunBot

I used yarn add instead of npm install to install my package (inside CRA project) , that worked, but would not consider the issue fixed

Thanks for sharing that. But using yarn may introduce other problems in the repo..

umair-mirza avatar Aug 27 '22 09:08 umair-mirza

I am also getting the same error. I have deleted the package-lock.json and re-run npm install and deleted node_modules, but no change.

tubone24 avatar Sep 07 '22 14:09 tubone24

Deleting node_modules, deleting packages-lock.json and running npm install worked for me.

umair-mirza avatar Sep 07 '22 14:09 umair-mirza

@umair-mirza Thanks a lot. That's what I meant. I understand.

I deleted package-lock.json and node_modules in my local PC environment and npm install worked, so I pushed the package-lock.json to my GitHub repository and ran npm install in CI. I asked because I get an error when I push the package-lock.json to my GitHub repository and run npm install with CI.

My understanding is that if you have package-lock.json and node_modules does not exist, npm install will go wrong. Maybe...

tubone24 avatar Sep 07 '22 15:09 tubone24

Having the same issue: while npm works fine locally, in CI it fails with the same error. It works if I push the code without package-lock.json, but that's far from ideal. Started happening after upgrading some dependencies to their latest versions: typescript to 4.8.2 eslint to 8.22.0 eslint-config-airbnb-typescript to 17.0.0

However a lot of other dependencies where updated up to their latest minor versions, so I don't know which ones have caused the error in particular.

Node and NPM versions in CI: node: v16.6.2 npm: v7.20.3

vykintazo avatar Sep 08 '22 13:09 vykintazo

not a solution but worked for me npm cache clean -f edit: looks like need to delete package-lock.json too prior too re-running npm install pretty much what @umair-mirza said above

jdc-cunningham avatar Oct 12 '22 19:10 jdc-cunningham

Same error, delete the node_modules/.cache and re-run scripts worked fine, the directory has ts-loader, babel-loader, vue-loader, eslint. Not sure if it is a bug of cache-loader (we just use cache-loader in our projects recentely

youthug avatar Oct 20 '22 02:10 youthug

'TypeError: The "path" argument must be of type string. Received undefined' seems to the same bug, both node v16 and node v18 have this bug, I delete package-lock and regenerat, still doesn't work.

cityvoice avatar Feb 17 '23 08:02 cityvoice

Any update here?

chgeo avatar Apr 25 '23 13:04 chgeo

Running into the same issue on Node 20.11.0 with NPM 10.2.4

brandbarr avatar Feb 06 '24 18:02 brandbarr

I was encountering this issue using node 20.11.0 with npm 10.4.0. After deleting node_modules/, deleting package-lock.json, upgrading npm to 10.5.0, and finally running npm i to generate a new package-lock.json with 10.5.0, I am no longer encountering this issue.

oconnorjoseph avatar Feb 29 '24 08:02 oconnorjoseph