Skip to content

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

Open
@bchenSyd

Description

@bchenSyd

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??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions