Heroku not running the postinstall or heroku-postbuild commands: - node.js

I'm trying to deploy an app that makes use of the MRE SDK to Heroku. As of this writing, the SDK itself is broken, and attempting to run an npm run build will result in an error.
A work around is to copy a modified animation.d.ts file over to the resulting node_modules folder, after the install (specifically ./node_modules/#microsoft/mixed-reality-extension-sdk/built/animation/).
I keep this file in a folder called v0.16_mre_fix.
Without this, the build will fail. So I added this to my package.json file.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "tsc --build --clean",
"heroku-postbuild": "cp -i ./v0.16_mre_fix/*.ts ./node_modules/#microsoft/mixed-reality-extension-sdk/built/animation/",
"build": "tslint -p ./tsconfig.json src/**/*.ts && tsc --build",
"lint": "tslint -p ./tsconfig.json src/**/*.ts",
"start": "node .",
"debug": "node --nolazy --inspect-brk=9229 ."
},
According to heroku here, heroku-postbuild will be run after installing dependencies. This, however, did not work.
So I tried changing it to heroku-prebuild and postinstall:. They didn't work either.
Am I missing something?
EDIT: I also tried
"heroku-prebuild": "echo This runs before Heroku installs your dependencies.",
but I didn't see any echo in the ensuing git push.

Related

How to run build in a parent directory, copy build into current directory before deploying to heroku

My friend had a bad folder structure, which he wanted me to contribute to, he had his backend in the client directory.
i wanted to separate the folder, he objected, so as not to loose previous git commit history. so i came up with this approach of running a script before deploying
i.e enters the client removes previous client build, runs new build and copy to backend. in the backend i serve the client build as a static file.
so after committing changes in both client and backend i ran
npm run dev
git push heroku
This approach worked very well, but i want only heroku or npm to run it before deploying, i tried changing my dev script to heroku-postbuild, heroku-prebuild, npm postinstall, and even build, but the build kept failing.
heroku-postbuild
"scripts": {
"start": "node server",
"heroku-postbuild": "cd ../ && rm -rf build && npm run build && cp -rf ./build ./backend/public",
"test": "echo \"Error: no test specified\" && exit 1"
},
heroku-prebuild
"scripts": {
"start": "node server",
heroku-prebuild": "cd ../ && rm -rf build && npm run build && cp -rf ./build ./backend/public",
"test": "echo \"Error: no test specified\" && exit 1"
},
it kept throwing this error,
and i understand why the error occurs, " cd ../" in the heroku-prebuild script refers to the client, which doesnt exist in the heroku repo i am deploying. pls what other approach can you recommend for me.

Can not run Nodemon in node project build with Typescript (In Windows)

Node project is built with Typescript and there are three script in package.json file but when I run it shows ...
If i run this project in ubuntu it works fine but not in windows
Image of output terminal
but after this nodemon is not start to run project.
Script in Package.json
"start": "tsc --watch & nodemon dist/index.js",
"lint": "tslint -c tslint.json 'src/**/*.ts' --fix",
"build": "tsc"
Help me to solve this, Thank you in advance :)
You seem to be missing an & character between tsc --watch and nodemon dist/index.js. A single & is not a valid and operator:
"start": "tsc --watch && nodemon dist/index.js",
Update It looks like the issue is on Windows. Commonly this issue is solved by using a library such as concurrently or cross-env to execute commands in a similar way on Windows. After you've installed concurrently:
"start": "concurrently \"tsc --watch\" \"nodemon dist/index.js\"",
Hopefully that helps!

Npm start deletes new files from .nuxt

Whenever I run "npm start" it always deletes, and even "reset" files, that I add in my .nuxt folder. As in, when I add, as an example, a new component in the .nuxt > "components" folder, press CTRL + C in cmd to stop the server and then restart running "npm start", it always "resets" the .nuxt folder to its initial/install state. Why is this happening?
I am using "FeathersJS" for backend and "NuxtJS" for frontend.
package.json:
"scripts": {
"test": "npm run eslint && npm run mocha",
"eslint": "eslint src/. test/. --config .eslintrc.js",
"build": "nuxt build",
"dev": "SET DEBUG=nuxt:* && nodemon --watch src/ --watch config/ src/index.js",
"prestart": "npm run build",
"start": "SET NODE_ENV=production && nodemon src/",
"mocha": "mocha test/ --recursive"
},
You shouldn't even add or delete anything from .nuxt. It is files generated by .nuxt. You should modify your sources only, not a generated files.
I have found my own solution now. The solution can be found here, for future reference: https://github.com/fexell/FeathersJS-NuxtJS

Using Nodemon or something similar to listen for changes, first build, then start?

Using Nodemon or something similar to listen for changes, first build, then start? Is it possible?
"scripts": {
"build": "npm run build:dll && webpack --progress",
"start": "node app.js",
}
Make sure nodemon is installed (npm install -g nodemon or npm install --save-dev nodemon) and then just change your package.json to this:
"scripts": {
"build": "babel lib -d build --copy-files",
"start": "nodemon build/index.js"
}
EDIT:
Add a nodemon.json on the root of your project, in there insert your build script in the "events.restart" section as documented here: https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md
"events": {
"restart": "your build script here"
}
And finally run with "npm run start". This run your app with nodemon and nodemon's configuration will execute your build very time you change your code (on restart)

Failed to write to file: ENOENT: no such file or directory

I am trying to build a folder with the name of build which will gonna contains number of map files and JavaScript files. But i'm getting an issue shown below.
Code :
"scripts": {
"prestart": "d2-manifest package.json manifest.webapp",
"start": "webpack-dev-server",
"test": "echo Everything probably works great\\! ## karma start test/config/karma.config.js --single-run true",
"build": "rm -rf build && set NODE_ENV=production webpack --progress && npm run manifest",
"postbuild": "cp -r src/i18n icon.png ./build/",
"validate": "npm ls --depth 0",
"manifest": "d2-manifest package.json build/manifest.webapp",
"deploy": "npm run build && mvn clean deploy",
"lint": "echo Looks good."
}
Error :
(I'm ignoring the fact that you seem to run this on a Windows machine)
The set command does not do what you think it does. To set an environment variable for a command, use
VARIABLE=value cmd
or
env VARIABLE=value cmd
This means changing
set NODE_ENV=production webpack --progress
into
env NODE_ENV=production webpack --progress
With set NODE_ENV=production webpack --progress you just set the positional parameters of the current shell instance to NODE_ENV=production, webpack and --progress.

Resources