Bower modules cache on heroku - node.js

I 've been using bower to install client-side dependencies, e.g. jquery and purecss, to my Node.js project. I add the following to my package.json and everything works like a charm - downloading the bower modules at deploy time.
"scripts": {
"postinstall": "bower install"
}
I was wondering though if it's possible to cache the modules, similar to how node-modules work, so I don't have to download them every-time I deploy my code. Any ideas how to do that?

It seems that there is no option to do this in the current nodejs buildpack.
There is a discussion about solving this here: https://github.com/heroku/heroku-buildpack-nodejs/pull/192/files

Heroku support custom cache directoies:
https://devcenter.heroku.com/articles/nodejs-support#cache-behavior

Related

How to deploy Node.js / Express app with typescript on heroku?

I want to deploy node.js / express server app on heroku.
I tried with this blog.
But it didn't work. The parts of my code are below.
server.ts
package.json
Ahh. You have messed up in the package.json file. What you have done is you have included the dependencies in the devDependencies.
Remember one thing always, when you are going to push an app to Heroku it prunes the devDependencies.
Actually, this is the main cause your server is not starting up because there are not required modules.
Run this command to move your devDependencies to dependencies:
npm install <module-name> --save-dev
This thing will solve your problem. If you face any other problem related to the configuration then follow this article - https://dev.to/hte305/simple-deploy-typescript-application-to-heroku-5b6g

react-scripts required old version of webpack

I installed webpack into my react project, but the same error occurred every time when I use npm start:
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.42.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\react\minimoj\node_modules\webpack (version: 4.43.0)
I tried to remove package-loc.json file + all node_modules + remove webpack name from package.json and reinstall it with npm install. Also I tried same with yarn, but it didn't help. I see that in node_modules version is 4.43 and after I use npm install webpack in the file package-loc.json it shows 4.43, but at the moment when I use npm start it changed to 4.42 and error occur. In addition I also reinstall node.js but it didn't help.
create .env file and add SKIP_PREFLIGHT_CHECK=true
I had similar with a newer webpack version being installed than what react_scripts required.
To fix I deleted webpack and webpack-dev-server from my project's node_modules, went to a console outside of the project dir and ran
npm uninstall webpack
npm uninstall webpack-dev-server
Then ran
npm install
npm run build
And all was well, as my package.json was correct without change.
Since webpack is mostly focused on common js according to some websites, I just tried rollup for my react project and it proved to be much more effective as it supports es+. I would highly recommend it. I took a couple minutes to have everything setup and ready. Also, as a good practice it is better to use yarn as npm has had a lot of known issues for node app management.

FAIL Inject RemoteDev monitor into React Native debugger

I am working on a React Native app and suddenly see this :
FAIL Inject RemoteDev monitor into React Native debugger, the file 'react-native\local-cli\server\util\debugger.html' not found.
when i run npm install.
It used to be ok before. I checked the folder AppData\Roaming\npm\node_modules\react-native\local-cli\server\util and the debugger.html file is there.
Here is my package.json script:
"postinstall": "remotedev-debugger"
How can I fix this?
I got this error today after updating to the latest React Native version.
I think you need to update RemoteDev package.
For me, this involved replacing remote-redux-devtools-on-debugger with the latest remotedev-rn-debugger (https://github.com/jhen0409/remotedev-rn-debugger) as the package name had changed.
Upgrade the remotedev-rn-debugger package.
If you use NPM:
npm i remotedev-rn-debugger#latest --save-dev
If you use Yarn:
yarn add remotedev-rn-debugger#latest --dev

How do I install Bower packages with Yarn?

From the project's README:
Multiple Registries: Install any package from either npm or Bower and keep your package workflow the same.
I'm assuming that means that I can install my Bower packages (listed in my project's bower.json) with Yarn. If this is the case, how would I go about doing that?
I'm not seeing any mention of Bower or using separate registries in the documentation. However, I do see the Bower registry listed in the source.
UPDATE 11/4/16: Yarn decided to remove support for Bower. See the Github pull request and Bower's blog. =(
ORIGINAL:
Bower just posted a blog post about this topic. They seem excited about it, but point out that there are currently unresolved issues:
Important note: As it stands right now there still seem to be some issues regarding Bower support. We are however confident that with the help of the community, these issues will be solved quickly as Yarn steps towards 1.0 in upcoming months.
He also refers to a pull request for a bower patch.
When I ran yarn, it deleted my bower_components folder (GitHub ticket here)! I really like yarn though, can't wait for the bower bugs to get resolved.
If you add the following to package.json, bower install will be called and it works. It is a workaround though:
"scripts": {
"postinstall": "bower install"
}
Apparently, it should just work. Unfortunately, there's currently a bug where, if you have both a package.json and bower.json in the same project, only the npm packages are installed and the bower packages are ignored.
Normally, one would simply yarn or yarn install and both npm and bower dependencies would be installed.

npm install: Use global package if it exists, rather than installing twice

When using npm install with a package.json file, how do I get it to use a globally installed package that meets the criteria instead of downloading and installing the package locally again?
I know about link, but is there a way to do what I'm describing?
Yarn seems to work much better with repeated dependencies. So try yarn install instead of npm install.
One way of doing it for a specific set of modules is removing these modules from the dependencies section and creating a prestart script that contains all the modules that you prefer having installed globally.
A simple example might look something like this:
"scripts": {
"test": "mocha",
"prestart": "npm i -g mocha mysql bluebird"
},
Instead of prestart you can use one of the other hooks such as preinstall and prepare.
Note that this won't work as-is with packages you want to publish and would require a bit more hacking.
Help on running scriipts: https://docs.npmjs.com/misc/scripts

Resources