Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

merge fix(docs): add npm run postinstall - #463

Closed
NorthDecoder wants to merge 2 commits into
freeCodeCamp:masterfrom
NorthDecoder:master
Closed

NorthDecoder wants to merge 2 commits into
freeCodeCamp:masterfrom
NorthDecoder:master

Conversation

@NorthDecoder

Copy link
Copy Markdown
Contributor
  • I have read Chapter's contributing guidelines.
  • My pull request has a descriptive title (not a vague title like Update README.md).
  • My pull request targets the master branch of Chapter.

Closes #462

The .env file is mandatory but not supplied by the project.
Running the postinstall script command will copy the
.env.example file into the .env file. If the .env exists,
the copy will not occur.

- The .env file is mandatory but not supplied by the project.
- Running the postinstall script command will copy the
- .env.example file into the .env file.
@gitpod-io

gitpod-io Bot commented Mar 26, 2021

Copy link
Copy Markdown

@allella

allella commented Mar 26, 2021 •

Copy link
Copy Markdown
Contributor

@NorthDecoder I believe the "Docker Mode" install will already run the post install script, so this may be best to add only in the "Manual Mode". Would you agree we could move this under the Manual Mode heading of Step 2 of Running the Application?

Also, I suspect this could merge in fine, but this PR is going master to master and step 5 of the CONTRIBUTING.md suggests all PRs be off a branch like docs/name-of-your-branch.

Thanks,
Jim

@allella

allella commented Mar 26, 2021 •

Copy link
Copy Markdown
Contributor

Actually, I don't think it's Docker that creates the .env.

I just did a fresh install and ran the
npx recursive-install
from Step 1 of Running the Application and it created a .env where one didn't exist before I ran it. It must be the case that this command runs the postinstall hook of package.json

  "scripts": {
....
    "postinstall": "node scripts/postInstall.js",

That step is for Docker Mode or Manual Mode. So, it would seem we don't need to manually call
npm run postinstall
as long as that step is run.

@allella

allella commented Mar 26, 2021

Copy link
Copy Markdown
Contributor

It looks like the "post" prefix in package.json scripts creates a special lifecycle hook that fires when npm install, or seemingly the related npx recursive-install are run.

So, that likely explains why running
npx recursive-install
executes scripts/postInstall.sh, which then creates a .env if it doesn't exist.

@NorthDecoder can you try a fresh test, like

mkdir chapter-test && cd chapter-test
git clone https://github.com/freeCodeCamp/chapter.git .
ls -la
npx recursive-install
ls -la

and see if the .env file gets created (via the output of the ls command before and after the npx)?

@NorthDecoder

Copy link
Copy Markdown
Contributor Author

I have removed project and started fresh again and found that the postinstall script was indeed run and the default .env file was created as expected. Therefore this pull request issue and the associated issue #462 can be closed, with understanding to continue review of wording in the contributing.md file.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add npm run postinstall to contributing.md

2 participants