-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] npm install doesn't create the .bin directory with a v6 package-lock #2147
Comments
We've noticed a few weird things relating to package scripts, npm v6/7, and lockfile v1/2 interoperability: https://twitter.com/jaydenseric/status/1318321502098345985?s=20 Each time we tried to remember the exact reproduction steps but ended up confused. |
Can you check with |
I also encountered this (on macOS, also 7.0.8). Upgrading to 7.0.10 did not fix the issue. |
The `package-lock.json` is bad and will not create `node_modules/.bin/` on wither `npm i` or `npm ci` The `package-lock-good-recreated-with-npm@7.0.8.json` is the supposed correct version Related issue: npm/cli#2147 --original commit message-- imagemin-min@0.1.1 notable change: - fix: add bin `#!` for `bin/test-boot.js`
Got the bug, too.
And a typical diff looks like: (good file will add "table": "^5.2.3",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
+ },
+ "bin": {
+ "eslint": "bin/eslint.js"
+ },
+ "engines": {
+ "node": "^10.12.0 || >=12.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
}
}, With the bad lockfile, |
Hello @isaacs , I just updated my npm to |
@closingin what package are your installing? |
Uh, I'm just doing a standard @isaacs I think I just found how to work around the bug. It may help you in finding the culprit. When you upgrade to node 15 / npm 7 and do any operation that would update your My bold prediction is that npm works correctly when installing, based on what it has in the lockfile. The problem surely comes from the first operation that updates the lockfile to version 2, I think it should either let the |
Might be related, I think the bad lockfile is created after apt updated |
A test to reproduce the bad lockfile from the itself: (with mkdir "test-lock/"
cd "test-lock/"
# copy the `package.json` and `package-lock.json-npm708-bad` file here
cp "package-lock.json-npm708-bad" "package-lock.json"
npx --yes npm@6 install
ls "node_modules/.bin/" # there's file
npx --yes npm@6 ci
ls "node_modules/.bin/" # there's file
cp "package-lock.json" "package-lock.json-npm6-good"
npx --yes npm@7.0.10 install
ls "node_modules/.bin/" # there's file because npm do not reset them yet
npx --yes npm@7.0.10 ci
ls "node_modules/.bin/" || echo "no file" # there's no file
cp "package-lock.json" "package-lock.json-npm710-bad-not-fixed" |
|
Apologies: I wrote too fast, issue not fixed. I did my test with @dr-js 's snippet, but the problem still exists on my personal project, using |
Hi @closingin do you happen to have a As I mentioned over in #1957 if that's the case you might already have a broken file and you would need to force the migration again in order to fix the missing bins issue. If that's the case you can try this trick: # Make sure you got npm@7.0.11 or newer:
$ npm install -g npm@7
# npm@6 install:
$ npx npm@6 install
# npm@7 install to migrate package-lock file again:
$ npm install
# You should have a fixed-up package-lock.json file now :) |
Alright, looks like it worked @ruyadorno, thanks! Sorry that I didn't find the existing issue and recreated one btw. |
I've had very similar problems too. I couldn't get it working properly on 6.14.8 and was considering doing some tests with earlier versions. However I decided to test out the process in a new Debian docker container, copied the basics of the package.json in my project and it built correctly using npm 7.0.14 with a.bin folder. I was confused! I copied the whole of my project package.json and it failed trying to load fortawesome-pro. I copied in my .npmrc and the build completed but there was no .bin folder. In my .npmrc there was this, I have no idea why!:
Removing this line solved the problem and the .bin folder was created correctly. |
1. Fixes package-lock.json using the method suggested by @ruyadorno: npm/cli#2147 (comment) The issue was causing missing binaries in the `/node_modules/.bin`. 2. Restores version to the package.json based on the latest git tag.
1. Fixes package-lock.json using the method suggested by @ruyadorno: npm/cli#2147 (comment) The issue was causing missing binaries in the `/node_modules/.bin`. 2. Restores version to the package.json based on the latest git tag.
1. Fixes package-lock.json using the method suggested by @ruyadorno: npm/cli#2147 (comment) The issue was causing missing binaries in the `/node_modules/.bin`. 2. Restores version to the package.json based on the latest git tag.
package-lock.json was migrated to "lockfileVersion": 2 by an old buggy version of npm@7, and is therefore missing important information such as the "bin" records that npm@7 needs for new installs. $ npm i; npm run build […] > flatpickr@4.6.9 build > run-s build:pre build:build build:esm build:types build:post sh: line 1: run-s: command not found Fix it by un-migrating with npm@6 and re-migrating with a current npm@7. npm/cli#2147 (comment) Signed-off-by: Anders Kaseorg <andersk@mit.edu>
node_modules/.bin was missing See npm/cli#2147 (comment)
Hello there, here's a little (but really annoying) bug I just found out !
Current Behavior:
I just upgraded to
node@15
andnpm@7
.When deleting my
node_modules
and reinstalling usingnpm i
, npm doesn't create the.bin
directory, which ends up in me having no working scripts at all (eg:npm run build
, supposed to runnext build
, but it can't find it obviously).If I delete my current
package-lock.json
and reinstall, the.bin
directory is correctly re-created, but I can't do that as it breaks my app.npm bin
correctly returns[redacted]/node_modules/.bin
.From what I can see in my git diff, my old
package-lock.json
does not have the"bin": {}
property on packages that have binaries, while the fresh one has it.Expected Behavior:
npm install
should create and populate the.bin
directory with olderpackage-lock.json
files, and upgrade the lock file.Steps To Reproduce:
Having a v6 package-lock I guess ? I don't know what's causing this, but I can give you my
package-lock.json
andpackage.json
if needed.Environment:
The text was updated successfully, but these errors were encountered: