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

Adding ability to run npm ci by default #236

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aksgupta14
Copy link

@aksgupta14 aksgupta14 commented Apr 22, 2020

Making npm ci to run by default and if it fails for any reason we will run npm install as a backup, this will prevent build from failure for developers who doesn't use or update package-lock.json.

This is the one way and another way is to use variable RUN_NPM_CI like we use NODE_ENV, but that would require existing developers to update their build_template and for new developers who are not aware of this env variable won't be able to use this approach.

Please refer below docs for more information:
npm ci
npm install

#212
@phracek please review.

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

5 similar comments
@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@rhscl-bot
Copy link

Can one of the admins verify this patch?

@rhscl-bot
Copy link

Can one of the admins verify this patch?

@rhscl-bot
Copy link

Can one of the admins verify this patch?

@phracek
Copy link
Member

phracek commented Apr 24, 2020

[test]

echo "---> npm ci failed, installing dependencies with npm install"; \
npm install

NODE_ENV=development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NODE_ENV=development

# npm ci will fail if certain conditions aren't met as mentioned in
# https://docs.npmjs.com/cli-commands/ci.html#description
echo "---> npm ci failed, installing dependencies with npm install"; \
npm install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
npm install
NODE_ENV=development npm install

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated my PR.

12/s2i/bin/assemble Outdated Show resolved Hide resolved
12/s2i/bin/assemble Outdated Show resolved Hide resolved
Copy link
Member

@phracek phracek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!.

Some changes are needed from my point of view.
NODE_ENV=development npm install has to be used.
I don't know why it was removed.

I guess the same has to be used also for npm ci, right?

@aksgupta14
Copy link
Author

@phracek that is correct will push updated PR. Also is there any changes that I have to make for the test to be successful?

@phracek
Copy link
Member

phracek commented Apr 27, 2020

[test]

@aksgupta14
Copy link
Author

@phracek can the test failure be because of npm ci throwing error?

@phracek
Copy link
Member

phracek commented Apr 27, 2020

@aksgupta14
The failure is:

---> Installing dependencies with npm ci
�[91mnpm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.
�[0m�[91m
npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/app-root/src/.npm/_logs/2020-04-27T08_37_33_712Z-debug.log
�[0m---> npm ci failed, installing dependencies with npm install

@aksgupta14
Copy link
Author

@phracek after going through the test cases, I was able to figure out the issue. The issue appears only with incremental build and the reason being npm ci removes all packages inside node_modules even though it fails, now when npm install is run it installs all the packages that is 121 packages which make it equal to the previous build, hence incremental build errors out by giving error ERROR Incremental build failed: both builds installed 121 packages.

Now when we will use npm ci it will always install the all packages irrespective of the packages already installed which will make this test case irrelevant. can you please advice as to how I should proceed with updating test cases?

@rhscl-automation
Copy link

Can one of the admins verify this patch?

@phracek
Copy link
Member

phracek commented Sep 3, 2020

I will investigate it a bit more after a couple days. Please be patient.

@gmahomarf
Copy link

@phracek Are there any updates on this feature?

@timaxxer
Copy link

timaxxer commented May 6, 2022

I am also looking for that capability, is there a plan to make npm ci avalable in the S2I?

@phracek
Copy link
Member

phracek commented Jul 14, 2022

[test-all]

@mhdawson
Copy link
Member

This PR seems to make the change for Node.js versions 10 and 12 which are no longer supported. While I can see the change with a working fallback makes sense to me I'd suggest it should only be made for the currently supported LTS versions.

This is probably because it was submitted many years ago. At this point I think we should likely only do for 16 so that we minimize risk to people already using the containers.

@helio-frota
Copy link

hi folks, friendly ping here about this PR.

We found a situation that maybe this feature can help us:
nodeshift-starters/devfile-sample#10 (comment)

This error is not happening when using the version 14.

@mhdawson
Copy link
Member

@aksgupta14 are you still willing/interested in getting this feature added? I know this is quite old but looking to see how we move it forward.

@phracek
Copy link
Member

phracek commented Oct 2, 2023

@aksgupta14 Can you please update this pull request? There are several conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants