When I push my code to OpenShift, it looks like it's installing my devDependencies
which takes forever. I would really love to set it up so it will only install the dependencies
(by running with the --production
flag). Is there any way to do this?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
- Webpack getting started, import error
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- How to obtain the enable admission controller list
Create a
.npmrc
file where thenode_modules
folder is located.Open it with your
text-editor
and add this to it:production = true
P.S. no semicolons or any other characters
This will ensure that
devDependencies
are not installed on theOPENSHIFT
serverYou can tell npm to install using the
--production
flag by setting theNPM_CONFIG_PRODUCTION
environment variable to "true
".Here is an example that should work for existing applications:
Or, you can set this variable as a part of your initial app-create step:
It looks like the only solution is to update the cartridge itself. The npm install command is located in the cartridge's bin/control folder. Meanwhile, it's been fixed in the originating github repo at wshearn/openshift-origin-cartridge-nodejs so you can just install from github rather than using the Quickstart.
Found a way to specify it in source instead of during app creation. The benefit (for me) over an env var is that it applies to all ways to launch the app, including a "Launch on OpenShift" button.
Create an
.openshift/action_hooks/pre_build
file:That's it! I've tested and it does affect npm for this build, and the .npmrc disappears if you remove this hook in the future.
(Obviously I could also achieve this by simply adding an
.npmrc
to my repo, but do not want to affect people checking out the source and runningnpm install
, only how it works on OpenShift.)