npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.44k stars 3.14k forks source link

[BUG] ENOTDIR error on npm install (npm 3 over node 4. I know: legacy. Sorry :( ) #5032

Closed daniel-alonso-sanchez closed 2 years ago

daniel-alonso-sanchez commented 2 years ago

Hi! First of all, my apologies for reporting a problem of npm3 here, but it looks like the old repo is currently in read only mode.

We have a big and old angularjs frontend app, that requires node4 and uses npm3. A couple of days ago, a problem raised when someone performed a npm install.

error

npm ERR! Linux 4.19.0-13-amd64
npm ERR! argv "/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqq/abc-batch-qqq/node/node" "/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqq/abc-batch-qqq/node/node_modules/npm/bin/npm-cli.js" "install"
npm ERR! node v4.4.3
npm ERR! npm  v3.10.10
npm ERR! path /home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqq/abc-batch-qqq/node_modules/.staging/@types/node-69b48d6f/package.json
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall open

npm ERR! ENOTDIR: not a directory, open '/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqq/abc-batch-qqq/node_modules/.staging/@types/node-69b48d6f/package.json'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

package.json

{
  "name": "abc",
  "version": "0.0.0",
  "description": "Description for abc",
  "private": true,
  "cacheDirectories": [
    "node_modules",
    "src/main/webapp/bower_components"
  ],
  "devDependencies": {
    "bower": "1.7.9",
    "browser-sync": "2.12.10",
    "del": "2.2.1",
    "eslint-config-angular": "0.5.0",
    "eslint-plugin-angular": "1.3.1",
    "event-stream": "3.3.4",
    "generator-jhipster": "3.4.2",
    "gulp": "3.9.1",
    "gulp-angular-filesort": "1.1.1",
    "gulp-angular-templatecache": "2.0.0",
    "gulp-autoprefixer": "3.1.0",
    "gulp-changed": "1.3.1",
    "gulp-cssnano": "2.1.2",
    "gulp-eslint": "3.0.1",
    "gulp-flatten": "0.3.0",
    "gulp-footer": "1.0.5",
    "gulp-htmlmin": "2.0.0",
    "gulp-if": "2.0.1",
    "gulp-imagemin": "3.0.2",
    "gulp-inject": "4.1.0",
    "gulp-natural-sort": "0.1.1",
    "gulp-ng-annotate": "2.0.0",
    "gulp-ng-constant": "1.1.0",
    "gulp-notify": "2.2.0",
    "gulp-plumber": "1.1.0",
    "gulp-rename": "1.2.2",
    "gulp-replace": "0.5.4",
    "gulp-rev": "7.1.0",
    "gulp-rev-replace": "0.4.3",
    "gulp-sourcemaps": "1.6.0",
    "gulp-uglify": "1.5.4",
    "gulp-useref": "3.1.0",
    "jasmine-core": "2.4.1",
    "karma": "1.1.2",
    "karma-chrome-launcher": "1.0.1",
    "karma-coverage": "1.1.1",
    "karma-jasmine": "1.0.2",
    "karma-junit-reporter": "1.1.0",
    "karma-phantomjs-launcher": "1.0.1",
    "karma-script-launcher": "1.0.0",
    "lazypipe": "1.0.1",
    "lodash": "4.14.0",
    "main-bower-files": "2.13.1",
    "map-stream": "0.0.6",
    "phantomjs-prebuilt": "2.1.9",
    "proxy-middleware": "0.15.0",
    "run-sequence": "1.2.2",
    "xml2js": "0.4.16",
    "yargs": "4.8.1",
    "useref": "1.4.1",
    "esquery": "1.0.1"
   },
  "engines": {
    "node": "^4.3"
  },
  "scripts": {
    "test": "gulp test"
  }
}

npm-debug

warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
150443 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
150444 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
150444 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
150444 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   linux
150444 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
150445 warn node-fetch@2.6.7 requires a peer of encoding@^0.1.0 but none was installed.
150446 verbose If you need help, you may report this error at:
150446 verbose     <https://github.com/npm/npm/issues>
150447 verbose stack Error: ENOTDIR: not a directory, open '/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq/node_modules/.staging/@types/node-69b48d6f/package.json'
150447 verbose stack     at Error (native)
150448 verbose cwd /home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq
150449 error Linux 4.19.0-13-amd64
150450 error argv "/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq/node/node" "/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq/node/node_modules/npm/bin/npm-cli.js" "install"
150451 error node v4.4.3
150452 error npm  v3.10.10
150453 error path /home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq/node_modules/.staging/@types/node-69b48d6f/package.json
150454 error code ENOTDIR
150455 error errno -20
150456 error syscall open
150457 error ENOTDIR: not a directory, open '/home/pparker/workspaces/eclipse/abc/abc_refactor/abc_qqqq/abc-batch-qqqq/node_modules/.staging/@types/node-69b48d6f/package.json'
150458 error If you need help, you may report this error at:
150458 error     <https://github.com/npm/npm/issues>
150459 verbose exit [ -20, true ]

I cannot upgrade to newer npm versions, because of the angularjs app and dependencies. I tried to move to npm6, but the application also packaging stopped working

Anyone have any clues about this? I'm completely desperated...

Thanks in advance and sorry again.

ljharb commented 2 years ago

Both node 4 and npm 3 are many years out of date, so if you can't upgrade, you're likely to remain broken - nobody's going to fix anything that old.

daniel-alonso-sanchez commented 2 years ago

Wow, but... It's funny, because this got broken this week after years of being working...

Same problem here from another guy

https://stackoverflow.com/questions/72631551/npm-install-in-docker-container-not-working/72646293?noredirect=1#comment128325278_72646293

Thank you so much for your response

daniel-alonso-sanchez commented 2 years ago

And is there any way to debug the npm source code in order to get an idea about what is happening?

Thanks again!

harveysanders commented 2 years ago

Man I just got a similar error trying to upgrade a Meteor project. Meteor bundles node/npm so I can't directly update node. I'll see if I can find any more detail tomorrow.

npm ERR! ENOTDIR: not a directory, open '[project-name]/node_modules/.staging/@types/node-151e4347/package.json'
cantremember commented 2 years ago

we are also experiencing the same problem ... suddenly

upon inspection, a node_modules/.staging is being created, and populated, with the proper files. however, maybe it just "looks right" after the fact. the (ancient) Many ENOENT / ENOTEMPTY errors in output says

Sometimes this results in race conditions

so maybe a file is missing at the time it is read, and is written milliseconds later? it's just conjecture

none of our binaries have changed in ages. in all candor, we're in the same situation as OP

We have a big and old angularjs frontend app, that requires node4 and uses npm3.

except that we're using ✨ Node 6

none of the following permutations work

we are able to yarn install with 'yarn@1.22.19' (under Node 6), enough so that our app launches. we're still in-flight, but we at least know that there's potential using yarn

daniel-alonso-sanchez commented 2 years ago

Hi folks! I found the problem!

It is related with the library generator-jhipster (or any of its dependencies)

We don't use it anymore, so i got rid of it and everything works again!

Thanks everybody!

pieterwillaert commented 2 years ago

I've experienced the same issue, but here it was because of @azure/storage-file-datalake Updating the dependency fixed the issue

ramnathkr commented 2 years ago

Hi @daniel-alonso-sanchez , Did you help how you identified that particular package is causing the issue? similar issue i'm also facing i have so many dependencies in package.json. its very difficult to find each and every package one by one.

daniel-alonso-sanchez commented 2 years ago

Hi @rmtsys ! I pointed into the right direction thanks to jenkins. We kepts two executions: a successful and a failed one. Comparing both I found that the successful process this package, but not, the failed one:

I found that library was included by generator-jhipster. After got rid of generator-jhipster, the problem stop.

Regards

dinager commented 2 years ago

Encountered same error, this happens after I ran npm cache clean, (before that it ran ok) I do not have an option to upgrade the node version as this is some legacy project. Is there anyway to solve it?

npm ERR! Darwin 20.5.0
npm ERR! argv "/Users/dina/.volta/tools/image/node/6.17.1/bin/node" "/Users/dina/.volta/tools/image/node/6.17.1/bin/npm" "install"
npm ERR! node v6.17.1
npm ERR! npm  v3.10.10
npm ERR! path /Users/dina/Documents/my-app/node_modules/.staging/@types/estree-3b8366c1/package.json
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall open

npm ERR! ENOTDIR: not a directory, open '/Users/dina/Documents/my-app/node_modules/.staging/@types/estree-3b8366c1/package.json'

This is my package.json

{
  "name": "my-app",
  "version": "0.0.0",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "start": "ember server",
    "build": "ember build",
    "build-prod": "ember build --production",
    "test": "ember test --silent -r xunit > tests/results/results.xml"
  },
  "repository": "",
  "engines": {
    "node": "6.9.4",
    "npm": "3.10.8"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@abcum/ember-helpers": "4.2.1",
    "@stripe/stripe-js": "^1.5.0",
    "acorn": "^6.1.0",
    "babel-cli": "^6.26.0",
    "babel-core": "6.26.3",
    "babel-preset-env": "^1.6.1",
    "babel-preset-latest": "^6.24.0",
    "broccoli-asset-rev": "^2.2.0",
    "ember-ajax": "0.7.1",
    "ember-array-helper": "^1.0.1",
    "ember-assign-polyfill": "2.6.0",
    "ember-cli": "2.4.0",
    "ember-cli-app-version": "^1.0.0",
    "ember-cli-babel": "^6.0.0",
    "ember-cli-content-security-policy": "0.4.0",
    "ember-cli-dependency-checker": "^1.2.0",
    "ember-cli-file-picker": "0.0.12",
    "ember-cli-htmlbars": "^1.0.1",
    "ember-cli-htmlbars-inline-precompile": "^0.4.0",
    "ember-cli-inject-live-reload": "^1.3.1",
    "ember-cli-json-module": "0.0.3",
    "ember-cli-qunit": "^1.1.0",
    "ember-cli-release": "0.2.8",
    "ember-cli-sass": "5.6.0",
    "ember-cli-showdown": "3.2.2",
    "ember-cli-uglify": "^1.2.0",
    "ember-disable-proxy-controllers": "^1.0.1",
    "ember-export-application-global": "^1.0.4",
    "ember-fetch": "5.1.3",
    "ember-intl": "2.27.0",
    "ember-load-initializers": "^0.5.0",
    "ember-paper": "0.2.15",
    "ember-radio-button": "1.0.7",
    "ember-resolver": "^2.0.3",
    "ember-truth-helpers": "1.2.0",
    "ember-wormhole": "0.3.5",
    "file-saver": "^1.3.2",
    "intl-format-cache": "2.1.0",
    "loader.js": "^4.0.0"
  },
  "volta": {
    "node": "6.17.1"
  },
  "dependencies": {}
}
dinager commented 2 years ago

figured out the issue by me ember-fetch was the cause of the problem.

The reason to the fail is dep of dep Merge pull request #125 from xg-wang/rollup_iife · ember-cli/ember-fetch@7199051

ember-fetch uses rollup-plugin-babel since version 5.1.2 which is not locked to a specific version that one of its updates fails npm 3 / node 6.

The solution was reverting to version ember-fetch to 5.1.1 which isn’t suppose to cause any breaking change.

how to figure out what package is breaking by you:

berteodosio commented 2 years ago

I was having the same issue. As others have pointed out, it might be related to a library on package.json. In my case it was browser-sync.

ob-juliandixon commented 2 years ago

how to figure out what package is breaking by you:

* Remove line by line in package.json and try to install

* After understanding which package it is, downgrade the version until it is installed

* Then check the package's package.json to check what changed

This was the approach that worked best for me! Thanks so much for the advice.

dspascucci commented 2 years ago

I was having the same issue. As others have pointed out, it might be related to a library on package.json. In my case it was browser-sync.

Exact same package causing the issue for me, thank you!

cstephens-cni commented 1 year ago

I imported the @types directly and I fixes that issue. I am not sure where it came from or what the lowest version of NPM is. that fixes this. Is this some automatic feature that some libraries updated to use it mid release? no idea.

Gionni commented 1 year ago

Same problem here after cleaning the cache, damn, I guess related to @types, what exactly did you import directly? every package or just what it sounded good?

In case thanks, G.

halofe commented 1 year ago

Upgrade npm from 4.6 to 6.9 fixes this issue on serveral machines.

dg-viseo commented 1 year ago

Instead of removing dependency and spending all that time (although it might optimize code by reducing unnecessary dependencies), just update the version of the node in the bitbucket-pipelines.yml file. In my case the image had: node:6.9.0, which I changed to node:12.16.0. This small change resolved my issue.