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

npm install fails after cloning a repo #780

Closed
michalczaplinski opened this issue Apr 12, 2021 · 5 comments · Fixed by #781
Closed

npm install fails after cloning a repo #780

michalczaplinski opened this issue Apr 12, 2021 · 5 comments · Fixed by #781
Assignees
Labels
bug Something isn't working

Comments

@michalczaplinski
Copy link
Member

michalczaplinski commented Apr 12, 2021

Expected behavior

npm install should succeed

Observed behavior

npm fails with the following error:

Screen Shot 2021-04-12 at 11 05 35

Steps involved to reproduce the problem

git clone git@github.com:frontity/frontity.git
cd frontity
npm install

Info about your system

node version 15
npm version 7.6.0

Possible solution

not yet clear

@michalczaplinski michalczaplinski added the bug Something isn't working label Apr 12, 2021
@michalczaplinski michalczaplinski self-assigned this Apr 12, 2021
@michalczaplinski
Copy link
Member Author

Running the contents of the build script of the @frontity/frontity package before running npm i at the root fixes the issue. Details:

Using the globally installed typescript I can run tsc --project ./tsconfig.build.json && cp -a templates dist/templates. Then, running npm i at the root succeeds.

The problem seems to be that lerna seems to try to run frontity somewhere before the @frontity/frontity package is built thus running into "no such file or directory" error.

@michalczaplinski
Copy link
Member Author

michalczaplinski commented Apr 12, 2021

After some more investigation, this is a bug in npm: npm/cli#3065

When npm tries to symlink the bin of the @frontity/frontity package it runs into this problem because the prepublish script was not run and thus the file does not exist.


Interestingly, the problem is a bit deeper than that. I can change the prepublish scripts in our packages to prepare and it still fails, albeit with a different error:

Screen Shot 2021-04-12 at 15 25 55

This would suggest that npm is still broken because it tries to run the prepublish script of @frontity/core before ensuring that all of its dependencies (in this case @frontity/file-settings have been built first.

I wasn't able to make a clean reproduction of this in a new repo to report to the npm team though. I might try again later on.


The simplest workaround for all of this for now would be to opt out of npm workspaces altogether by just deleting the:

"workspaces": [
  "packages/*"
]

in our root package.json. I've tested it and it seems to work fine.

@luisherranz You have added the npm workspaces to our main package.json file - is there some reason that I don't see for using them?

@luisherranz
Copy link
Member

You have added the npm workspaces to our main package.json file - is there some reason that I don't see for using them?

I added them so npx changeset suggestions are only shown for the packages that can be released.

Changesets don't support lerna: changesets/changesets#130.

Screenshot 2021-04-13 at 08 31 45

Without it, it makes suggestions for all package.json found:

Screenshot 2021-04-13 at 08 33 59

So it is not really required. We can remove it for now. I'll make a PR 🙂

@michalczaplinski
Copy link
Member Author

ok nice! I think that changesets should support lerna now. They switched to using @manypkg/get-packages which has support for lerna.

@luisherranz
Copy link
Member

Good to know 👍 🙂

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

Successfully merging a pull request may close this issue.

2 participants