Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
wjureczka opened this issue May 17, 2022 · 17 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@wjureczka
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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 wjureczka added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels May 17, 2022
@wjureczka wjureczka changed the title [BUG] <title> [BUG] TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. May 17, 2022
@mhamzas
Copy link

mhamzas commented Jun 12, 2022

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

@AverageHelper
Copy link

AverageHelper commented Jun 14, 2022

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. 🤷

@SimRunBot
Copy link

SimRunBot commented Aug 24, 2022

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

@umair-mirza
Copy link

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

@SimRunBot
Copy link

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

@umair-mirza
Copy link

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..

@tubone24
Copy link

tubone24 commented Sep 7, 2022

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.

@umair-mirza
Copy link

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

@tubone24
Copy link

tubone24 commented Sep 7, 2022

@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...

@vykintazo
Copy link

vykintazo commented Sep 8, 2022

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

@jdc-cunningham
Copy link

jdc-cunningham commented Oct 12, 2022

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

@youthug
Copy link

youthug commented Oct 20, 2022

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

@cityvoice
Copy link

'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.

@chgeo
Copy link

chgeo commented Apr 25, 2023

Any update here?

@brandbarr
Copy link

Running into the same issue on Node 20.11.0 with NPM 10.2.4

@oconnorjoseph
Copy link

oconnorjoseph commented Feb 29, 2024

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.

@webdev23
Copy link

webdev23 commented Oct 27, 2024

Can any sane person introduce HUMAN alike error logs in this ecosystem.

As of 2024, 90% of libraries aren't running out of the box, all we have remaining are HIPSTERS errors similar to:

terser myscript.js --source-map base --compress -o garbage.min.js
TypeError: The "from" argument must be of type string. Received type boolean (true) at Object.relative (node:path:1222:5) (...)(...)250 similar lines

By not taking care of log messages and debugging, and letting it go for years, as shown from the issue in this page, you had shot yourself in the foot.

This ecosystem is now to be considered obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests