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

yarn doesn't run prepublish script and include EVERTHING into the package when adding a local dependency #1671

Open
bochen2014 opened this Issue Nov 4, 2016 · 24 comments

Comments

Projects
None yet
@bochen2014

bochen2014 commented Nov 4, 2016

Hi there,
I'm building my own package and I have an example folder in my project as a demo. My project structure is like this:

   -root
     - node_modules
     - example
           -node_modeules
               - my-library
        -index.html
        -index.js
        -package.json 
      - src
          -library.js
      readme.md
      package.json 

Inside example folder, the package.json file has

"dependencies":{
    "my-library":"file:../"
}

and when I run npm install, I can see my library prepublish script is invoked and that my project is built and finally added to example\node_modules\ . This is exactly what I expected.

However, When I tried the same thing using yarn install, it didn't work, at all. Note I have cleared yearn cache, so it's not a cache issue. The problem is like, when running yarn install, it seems yarn doesn't honour my package.json defined in root folder. my /root/package.json has

    "name":"my-library"
    "version":"1.0.0"
    "main":"lib/result.js"
    "files":"["lib"]"
    "script":{
        "prepublish":"create a lib folder and put the compiled result into it"
   }

Basically, yarn ignored files section, which tells npm/yarn to only include lib folder in the result package, and built everything into the result package. I can also confirm that yarn is not calling prepublish script as npm does in this case

note: if I publish my library to npm registry, and then do yarn install my-library everything works as expected.

any ideas??

@bochen2014 bochen2014 changed the title from yarn doesn't call prepublish script and install EVERTHING when adding local package to yarn doesn't run prepublish script and install EVERTHING when adding local package Nov 4, 2016

@bochen2014

This comment has been minimized.

Show comment
Hide comment
@bochen2014

bochen2014 Nov 4, 2016

Also, I did another test

-root
    - example
        -package.json
    -lib
      -lib.js
    -src
      -test.js
    package.json

in root\package.json, try

    "name":"parent",
    "main":"lib\lib.js",
    "files":["lib"]

then in root\example\package.json, have

dependencies:{
   "parent":"file:../"
}

to test the difference

  1. cd root\example\; npm install
  2. cd root\example\; yarn install

compare the result in root\example\node_modues\parent\

the npm one only has lib folder, but the yarn one has everything (both lib and src )

why is such a case?

bochen2014 commented Nov 4, 2016

Also, I did another test

-root
    - example
        -package.json
    -lib
      -lib.js
    -src
      -test.js
    package.json

in root\package.json, try

    "name":"parent",
    "main":"lib\lib.js",
    "files":["lib"]

then in root\example\package.json, have

dependencies:{
   "parent":"file:../"
}

to test the difference

  1. cd root\example\; npm install
  2. cd root\example\; yarn install

compare the result in root\example\node_modues\parent\

the npm one only has lib folder, but the yarn one has everything (both lib and src )

why is such a case?

@bochen2014

This comment has been minimized.

Show comment
Hide comment

bochen2014 commented Nov 4, 2016

@MarshallOfSound

This comment has been minimized.

Show comment
Hide comment
@MarshallOfSound

MarshallOfSound Nov 4, 2016

What version of yarn are you running?

MarshallOfSound commented Nov 4, 2016

What version of yarn are you running?

@bochen2014

This comment has been minimized.

Show comment
Hide comment
@bochen2014

bochen2014 Nov 4, 2016

$ yarn info
yarn info v0.16.0

bochen2014 commented Nov 4, 2016

$ yarn info
yarn info v0.16.0

@bochen2014 bochen2014 changed the title from yarn doesn't run prepublish script and install EVERTHING when adding local package to yarn doesn't run prepublish script and include EVERTHING into the package when adding a local dependency Nov 4, 2016

@galvanu

This comment has been minimized.

Show comment
Hide comment
@galvanu

galvanu Jan 25, 2017

I'm facing the same issue, do you have any work around for this?

galvanu commented Jan 25, 2017

I'm facing the same issue, do you have any work around for this?

@tylerbuchea

This comment has been minimized.

Show comment
Hide comment
@tylerbuchea

tylerbuchea Feb 5, 2017

I'm having the same issue for now I'm going to have to switch to using regular old npm so I can develop my SDK in tandem with my application 😢

tylerbuchea commented Feb 5, 2017

I'm having the same issue for now I'm going to have to switch to using regular old npm so I can develop my SDK in tandem with my application 😢

@bochen2014

This comment has been minimized.

Show comment
Hide comment
@bochen2014

bochen2014 commented Feb 5, 2017

@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Apr 4, 2017

I have the same problem with yarn 0.21.3

montogeek commented Apr 4, 2017

I have the same problem with yarn 0.21.3

@itsnotvalid

This comment has been minimized.

Show comment
Hide comment
@itsnotvalid

itsnotvalid Apr 5, 2017

it's been like this since first public release but, this behavior is entirely different from npm.

itsnotvalid commented Apr 5, 2017

it's been like this since first public release but, this behavior is entirely different from npm.

@Startouf

This comment has been minimized.

Show comment
Hide comment
@Startouf

Startouf Apr 14, 2017

Hey any work on this ? I'd like to easily be able to fork github projects, contribute, and keep using my forks until the PR pass and I can revert to using the main repo.
Since yarn isn't doing the prepublish step it won't create the dist/ folder and I can't run my components

I know some prepublish steps are complicated but for most small projects I assume it should be fine to always have yarn try it ?

Startouf commented Apr 14, 2017

Hey any work on this ? I'd like to easily be able to fork github projects, contribute, and keep using my forks until the PR pass and I can revert to using the main repo.
Since yarn isn't doing the prepublish step it won't create the dist/ folder and I can't run my components

I know some prepublish steps are complicated but for most small projects I assume it should be fine to always have yarn try it ?

@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Apr 14, 2017

I did some initial exploration on the bug, I see that lifehook scripts are executed but are not treated as commands

montogeek commented Apr 14, 2017

I did some initial exploration on the bug, I see that lifehook scripts are executed but are not treated as commands

@bestander bestander removed the needs triage label May 23, 2017

@Slapbox

This comment has been minimized.

Show comment
Hide comment
@Slapbox

Slapbox Jun 18, 2017

This also seems to be the case for forked projects added via Github address.

Slapbox commented Jun 18, 2017

This also seems to be the case for forked projects added via Github address.

@cettoana

This comment has been minimized.

Show comment
Hide comment
@cettoana

cettoana Jul 12, 2017

Facing the same issue. May I know is there any update?

cettoana commented Jul 12, 2017

Facing the same issue. May I know is there any update?

@dgreene1

This comment has been minimized.

Show comment
Hide comment
@dgreene1

dgreene1 Aug 3, 2017

Subscribing so I can know when this is fixed.

dgreene1 commented Aug 3, 2017

Subscribing so I can know when this is fixed.

@aequasi

This comment has been minimized.

Show comment
Hide comment
@aequasi

aequasi Sep 25, 2017

Reported almost a year ago, and no updates?

aequasi commented Sep 25, 2017

Reported almost a year ago, and no updates?

zenmumbler added a commit to verifeyemedia/react-native-s3 that referenced this issue Oct 3, 2017

add postinstall script for lib download
Yarn does not run the prepublish script on install so add the download phase to postinstall as well for now. (yarnpkg/yarn#1671)

@darknoon darknoon referenced this issue Oct 5, 2017

Closed

Fix: New version #8

paradoxxxzero added a commit to paradoxxxzero/react-draft-wysiwyg that referenced this issue Oct 10, 2017

@suchitagarwal

This comment has been minimized.

Show comment
Hide comment
@suchitagarwal

suchitagarwal Nov 13, 2017

same here. i forked a github repo, made my changes and when i try to install using my github URL, it doesnt run the prepublish step and doesn’t build the module. i changed the main in package.json in my fork to work around this, but would be nice if yarn handled this itself.

suchitagarwal commented Nov 13, 2017

same here. i forked a github repo, made my changes and when i try to install using my github URL, it doesnt run the prepublish step and doesn’t build the module. i changed the main in package.json in my fork to work around this, but would be nice if yarn handled this itself.

h0rm added a commit to h0rm/react-dropdown-tree-select that referenced this issue Nov 27, 2017

h0rm added a commit to h0rm/react-dropdown-tree-select that referenced this issue Nov 28, 2017

@benjcallaghan

This comment has been minimized.

Show comment
Hide comment
@benjcallaghan

benjcallaghan Nov 28, 2017

I'm having the same issue as @suchitagarwal. When I run yarn install, I can see that the prepare script of my forked GitHub repo is being run, but the generated files are not being included in the node_modules folder. This works fine on my macOS systems, but fails on all of my Windows systems.

benjcallaghan commented Nov 28, 2017

I'm having the same issue as @suchitagarwal. When I run yarn install, I can see that the prepare script of my forked GitHub repo is being run, but the generated files are not being included in the node_modules folder. This works fine on my macOS systems, but fails on all of my Windows systems.

@benmcmaster

This comment has been minimized.

Show comment
Hide comment
@benmcmaster

benmcmaster Jan 9, 2018

Ugh. I am having this issue too. What has everyone been using as a workaround?

benmcmaster commented Jan 9, 2018

Ugh. I am having this issue too. What has everyone been using as a workaround?

@suchitagarwal

This comment has been minimized.

Show comment
Hide comment
@suchitagarwal

suchitagarwal Jan 9, 2018

@benmcmaster, because I had forked the repo, I just changed the main in package.json to do what i needed it to do.

suchitagarwal commented Jan 9, 2018

@benmcmaster, because I had forked the repo, I just changed the main in package.json to do what i needed it to do.

@benmcmaster

This comment has been minimized.

Show comment
Hide comment
@benmcmaster

benmcmaster Jan 9, 2018

@suchitagarwal interesting! Can you share your example?

benmcmaster commented Jan 9, 2018

@suchitagarwal interesting! Can you share your example?

@suchitagarwal

This comment has been minimized.

Show comment
Hide comment
@suchitagarwal

suchitagarwal Jan 9, 2018

It's a private repo, so I can't share that directly. But actually what I did was slightly different. I forked the repo, ran the prepublish, checked in the output to my fork, and then used that instead.

suchitagarwal commented Jan 9, 2018

It's a private repo, so I can't share that directly. But actually what I did was slightly different. I forked the repo, ran the prepublish, checked in the output to my fork, and then used that instead.

@Slapbox

This comment has been minimized.

Show comment
Hide comment
@Slapbox

Slapbox Feb 27, 2018

Here's the first example I've found which isn't a local package, but rather a Github branch. Post-installs don't run, so the package is not usable without additional work.

yarn add https://github.com/tomkp/react-split-pane/tarball/2516ee2de023cc51e9a18e471f42b608be19c8ad

Expected results:

  • React-split-pane installs
  • node_modules\react-split-pane\lib\ exists and contains built project files.

Actual results:

  • React-split-pane installs
  • node_modules\react-split-pane\lib\ DOES NOT exist.

Slapbox commented Feb 27, 2018

Here's the first example I've found which isn't a local package, but rather a Github branch. Post-installs don't run, so the package is not usable without additional work.

yarn add https://github.com/tomkp/react-split-pane/tarball/2516ee2de023cc51e9a18e471f42b608be19c8ad

Expected results:

  • React-split-pane installs
  • node_modules\react-split-pane\lib\ exists and contains built project files.

Actual results:

  • React-split-pane installs
  • node_modules\react-split-pane\lib\ DOES NOT exist.
@Slapbox

This comment has been minimized.

Show comment
Hide comment
@Slapbox

Slapbox Feb 27, 2018

This issue has been open for well over a year now. Is there any plan to address this? We've not seen a single response from a maintainer on this issue, and it is seriously detrimental to need to spend so much extra time to get packages working because yarn simply neglects to run this command in certain circumstances.

Slapbox commented Feb 27, 2018

This issue has been open for well over a year now. Is there any plan to address this? We've not seen a single response from a maintainer on this issue, and it is seriously detrimental to need to spend so much extra time to get packages working because yarn simply neglects to run this command in certain circumstances.

@rtsao

This comment has been minimized.

Show comment
Hide comment
@rtsao

rtsao Feb 27, 2018

@Slapbox I did some initial investigation into the bug in #5235 which discusses the root cause and how it might be fixed. I think making a patch for this would be a fairly reasonable undertaking, hopefully someone will be able to tackle this.

Agreed this is a high priority bug!

rtsao commented Feb 27, 2018

@Slapbox I did some initial investigation into the bug in #5235 which discusses the root cause and how it might be fixed. I think making a patch for this would be a fairly reasonable undertaking, hopefully someone will be able to tackle this.

Agreed this is a high priority bug!

pvinis added a commit to pvinis/chrome-headless-render-pdf that referenced this issue Apr 1, 2018

jaredh159 added a commit to jaredh159/friends that referenced this issue Jul 17, 2018

jaredh159 added a commit to jaredh159/friends that referenced this issue Jul 17, 2018

GrandVizierOlaf added a commit to GrandVizierOlaf/react-usa-map that referenced this issue Aug 12, 2018

jaredh159 added a commit to friends-library/friends-library that referenced this issue Aug 26, 2018

clintandrewhall added a commit to clintandrewhall/react-snapshot that referenced this issue Sep 9, 2018

clintandrewhall added a commit to clintandrewhall/react-snapshot that referenced this issue Sep 9, 2018

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