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?]: yarn postinstall script doesn't execute #5276

Closed
1 task
oceandrama opened this issue Feb 17, 2023 · 7 comments
Closed
1 task

[Bug?]: yarn postinstall script doesn't execute #5276

oceandrama opened this issue Feb 17, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@oceandrama
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

As mentioned in docs postinstall script should execute after packages are written to the disk, but it doesn't

To reproduce

.yarnrc.yaml

yarnPath: .yarn/releases/yarn-3.4.1.cjs
nodeLinker: node-modules

package.json

{
  "dependencies": {
    "husky": "8.0.3"
  },
  "scripts": {
    "postinstall": "echo Success"
  }
}

terminal

yarn

output:

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 0s 96ms

no Success message

Environment

System:
  OS: Windows 10 10.0.19044
  CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz 
Binaries:
  Node: 16.19.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 3.4.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD

Additional context

No response

@oceandrama oceandrama added the bug Something isn't working label Feb 17, 2023
@arcanis
Copy link
Member

arcanis commented Feb 17, 2023

Yarn doesn't print the postinstall output, unless they fail.

@arcanis arcanis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2023
@wataruian
Copy link

wataruian commented Mar 26, 2023

@arcanis I see that this issue was closed.

But my postinstall script is not working now.

After updating yarn to v3.5.0, postinstall script does not get called after yarn install, this works before updating (yarn v3.2.0)

To simplify the script just do something like this:

"postinstall": "touch test.txt"

The file is not created.

I am using these versions:
MacOS: 13.1 (Ventura) on M1 chip
Node: v18.15.0

@wataruian
Copy link

Update:

I just noticed that postinstall script only gets called when there are actual changes to the .yarn/node_modules like installing new packages or removing existing packages.

So if you invoke yarn install without those changes, the postinstall script will not trigger.

@dev-richardnguyen
Copy link

I still get this error although it's closed. Please help if you can

@b3nab
Copy link

b3nab commented May 28, 2024

this should stay open until solved

@clemyan
Copy link
Member

clemyan commented May 28, 2024

@dev-richardnguyen @b3nab
There is nothing to solve. The original issue describes a situation where a postinstall script executes successfully but its output (stdout and stderr) is not printed. This is working as intended and not a bug. You can override this behavior with the enableInlineBuilds config

If you have a different situation, please open a new bug report with reproduction, or an enhancement request with justification.

@b3nab
Copy link

b3nab commented May 28, 2024

I'm referring to @wataruian issue. Basically yarn runs postinstall only if there is a change in the dependencies of to node_modules. On npm the behaviour is different and those pre/post scripts are called every time as far as I know.

I was not able to find a way to restore the same behaviour of npm, that's all.

EDIT: @clemyan you're right, the original issue describe a different problem which surely can be solved with the config you wrote.

I think there was a confusion and the real issue is already opened here yarnpkg/yarn#5476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants