Skip to content

[BUG] NPM Install generates TAR_ENTRY_ERROR ENOENT: no such file or directory #3910

Closed

Description

@EvanCarroll

This bug is observed anytime you install by targeting a repo with git+http that contains an npm workspace. In the below example, I am creating this with Angular library which is itself an npm workspace. However, this bug may be possible to create without workspaces too.

I believe the question here is what is the desired behavior with

npm install git+https://server.com/npm_workspace.git

Currently the behavior is erratic unpredictable and loud.

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

One of three things will happen, you'll get an error like this,

npm WARN using --force Recommended protections disabled.
npm WARN tar ENOENT: Cannot cd into '/usr/local/lib/node_modules/my-workspace/node_modules/tslib'
npm WARN tarball tarball data for tslib@https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz (sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==) seems to be corrupted. Trying again.
npm WARN tar ENOENT: Cannot cd into '/usr/local/lib/node_modules/my-workspace/node_modules/tslib'
npm WARN tarball tarball data for tslib@https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz (sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==) seems to be corrupted. Trying again.
npm ERR! code ENOENT
npm ERR! path /usr/local/lib/node_modules/my-workspace/node_modules/tslib
npm ERR! enoent ENOENT: Cannot cd into '/usr/local/lib/node_modules/my-workspace/node_modules/tslib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-10-18T18_58_34_554Z-debug.log

Or you may get a lot of errors like this,

npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/add'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/add'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/internal'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/internal'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/observable'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/operator'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/operators/zip.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/add/operator/zipAll.d.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/internal/operators/zipAll.d.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/operator/zipAll.d.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/operators/zipAll.d.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/add'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/internal'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/operator'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/operators/zipAll.ts'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/_esm2015/LICENSE.txt'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/_esm5/LICENSE.txt'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/LICENSE.txt'
npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/usr/local/lib/node_modules/my-workspace/node_modules/rxjs/src/LICENSE.txt'

Or it may just work, god speed!

Expected Behavior

It works or fails consistantly with a reason.

Steps To Reproduce

  1. Have an npm-workspace up
    #. Follow these instructions to create a boiler plate angular library after you run those commands be sure commit all the file
    #. Use this one that I've created here
  2. Run npm install -gf "git+https://github.com/EvanCarroll/trash_npm_test.git" (or target the repo you've created)

Note if you don't want to pollute your environment you can do this in Alpine with a user namespaced container with

$ podman run -ti node:16-alpine /bin/sh
# apk add git
# npm install -gf "git+https://github.com/EvanCarroll/trash_npm_test.git

Environment

  • OS: tested on Debian Bullseye, and Alpine
  • Node: tested on Node v16.11.1
  • npm: tested on 7.24.1, 8.0.0, 8.1.0

Note, I believe this error report speaks to these questions on StackOverflow,

It's hard to even scope this problem, as there are over 1000 questions which include an ENOENT generated on install

Activity

  1. added
    Bugthing that needs fixing
    Needs Triageneeds review for next steps
    Release 8.xwork is associated with a specific npm 8 release
    on Oct 18, 2021
  2. changed the title [-][BUG] TAR_ENTRY_ERROR ENOENT: no such file or directory[/-] [+][BUG] NPM Install generates TAR_ENTRY_ERROR ENOENT: no such file or directory[/+] on Oct 18, 2021
  3. added and removed
    Needs Triageneeds review for next steps
    on Oct 22, 2021
  4. dominykas commented on Nov 9, 2021

    @dominykas

    Can confirm I can see this as well in 8.1.3.

    I guess I can just add that the net result in the global folder is a symlink to a folder under ~/.npm/_cache/tmp, which has no files (only the directory structure).

  5. DavidHooper commented on Nov 11, 2021

    @DavidHooper

    Having the same issue upgrading from docker node version 12 to 16 with npm 8 where npm install is happening on a mounted volume. The only way to make it work is by installing in another directory and moving node_modules over to the mounted volume. This was working with npm 5.

    An example script below for how we overcome the issue.

    # script to install npm packages outside of mounted docker volume
    # mounted docker volumes on mac don't work when installing via npm
    # only use this script if npm install is failing due to chmod or tar errors
    
    SECONDS=0
    
    mkdir /tmp/npm-install
    cp /usr/src/package.json /tmp/npm-install
    cp /usr/src/package-lock.json /tmp/npm-install
    cd /tmp/npm-install
    npm install
    echo "$(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds elapsed."
    echo "moving node_modules into workspace, this may take a while"
    mv -f /tmp/npm-install/node_modules /usr/src/node_modules
    echo "$(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds elapsed."
    echo "complete"
    
  6. mrrobbins commented on Nov 17, 2021

    @mrrobbins

    I am also experiencing this error with npm install. It produces many errors like:

    npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat <omitted/some/node_module/path>

    which fails the install with the below as the final output:

    npm ERR! code ENOENT
    npm ERR! path <omitted/some/node_module/path>
    npm ERR! enoent ENOENT: Cannot cd into '<omitted/some/node_module/path>'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent
    

    I am able to reproduce with npm 7 and npm 8 using various projects. The error does not happen with npm 6.
    Related to @DavidHooper comment, my company uses virtualized Windows machines with mounted disk volumes. This is preventing us from using Node.js 16 with npm 8.

  7. DavidHooper commented on Nov 18, 2021

    @DavidHooper

    Update on what we've moved to over the last week.

    Moved to Docker Sync, which works well for us on macs. We no longer have the npm issue due to not having to deal with host mounted volumes.

    https://docker-sync.readthedocs.io/en/latest

  8. mrrobbins commented on Nov 29, 2021

    @mrrobbins

    We are still stuck on this issue preventing us from using npm 8 within our company. This appears to be related to mounted drives. Do we know what the cause of the issue is?

  9. nlf commented on Mar 24, 2022

    @nlf
    Contributor

    can you folks try this again with the latest npm release? version 8.5.5 had some fixes related to workspaces within git dependencies that i think should resolve this. i'm unable to reproduce it after updating.

  10. self-assigned this
    on Mar 24, 2022
  11. mshima commented on Mar 24, 2022

    @mshima

    I've just got hit by some error like this using npm install -g github:mshima/generator-jhipster-ionic#esm

  12. nlf commented on Mar 28, 2022

    @nlf
    Contributor

    I've just got hit by some error like this using npm install -g github:mshima/generator-jhipster-ionic#esm

    was this with npm@8.5.5?

  13. mshima commented on Mar 29, 2022

    @mshima

    I've just got hit by some error like this using npm install -g github:mshima/generator-jhipster-ionic#esm

    was this with npm@8.5.5?

    yes.

    npm --version
    8.5.5
    
  14. nlf commented on Apr 11, 2022

    @nlf
    Contributor

    I've just got hit by some error like this using npm install -g github:mshima/generator-jhipster-ionic#esm

    was this with npm@8.5.5?

    yes.

    npm --version
    8.5.5
    

    i'm unable to reproduce this. using your command as-is, i get an error that reads:

    npm ERR! The git reference could not be found
    npm ERR! command git --no-replace-objects checkout esm
    npm ERR! error: pathspec 'esm' did not match any file(s) known to git
    

    but this is because the esm branch does not exist in your repository any more. dropping it and installing the main branch does not show the error for me. are you still able to reproduce this?

  15. mshima commented on Apr 11, 2022

    @mshima

    @nlf just realized that my problem was related to husky requiring "prepare": "husky install" script.
    prepare is not exclusive to dev and husky is a dev dependency.
    So prod install was broken. npm install -g jhipster/generator-jhipster-ionic is working after removing the prepare script.

    Thanks.

  16. nlf commented on Apr 12, 2022

    @nlf
    Contributor

    I'm going to close this issue, if anyone is still experiencing problems like this please open a new issue and provide as much information as you can to help us reproduce the problem you're seeing.

  17. ng-druid commented on Jun 8, 2022

    @ng-druid

    I had same issue today for my first time using github actions. The problem seems to be isolated to node version 14.x. I changed the node version to 16.x and the dependencies in package json installed without these critical errors.

  18. ramakrishna-kodukula commented on Mar 9, 2023

    @ramakrishna-kodukula

    I'm getting error when i try to create a my first angular app with below versions.
    Angular CLI: 15.2.1
    Node: 18.15.0
    Package Manager: npm 9.5.0
    OS: win32 x64

    npm ERR! errno -4058
    npm ERR! enoent ENOENT: no such file or directory, open 'D:\Examples\Angular\myApp\node_modules.bin\ng.ps1'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent

  19. afa4 commented on Jul 20, 2023

    @afa4

    Nice workarround bro, thanks @DavidHooper

  20. vivostar commented on Oct 14, 2023

    @vivostar

    the problem just come from local machine file handler limits. We should check it on current session

    ulimit -n

    if the number is so small, we should change it larger.
    that work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 1high priority issueRelease 8.xwork is associated with a specific npm 8 release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions