When I try to deploy the following repo to CF/BlueMix I got errors for the "devDependencies":
Error: Cannot find module 'webpack'
If I add webpack to the dep I got error
Error: Cannot find module 'postcss-cssnext'
and continue for other dev dep....
Which part of the devDependencies , does the deploy shouldn't install only the "prod" dependency?
This is the repo: https://github.com/Hashnode/mern-starter
I run the build locally with npm run bs
and I put in the manifest.yml the following
---
applications:
- name: myapp
buildpack: nodejs_buildpack
memory: 512M
command: npm run start:prod
services:
- mong
what could be the reason of faliing on devdependencies ?
Also,
Source: See the comments from this question: unable to push node.js cloudant app to bluemix
Update
I think I have reproduced the problem:
The webpack import issue seems to be with the file
dist/server.bundle.js
which for me was generated by the commandnpm run bs
.The dist folder is getting uploaded to Bluemix and appears to be getting imported when your app starts.
Can you exclude the dist folder in
.cfignore
and build it when your app is uploaded withcf push
? I'm not sure if you add multiple commands in manifest.yml, e.g.However, it looks as though whatever you do in your new build command (e.g.
npm run bs:prod
) only picks up production dependencies when it creates your dist folder.If you can't run multiple commands from the manifest.yml, then you may need to change
start:prod
so that it also performs a build step for the production environment.Update 2
You can ask the node buildpack to not cache modules and download them each time you push by using
NODE_MODULES_CACHE: false
, e.g.