Deploying an angular 6 app using fabric.js on heroku - heroku

I have to deploy an angular 6 application that uses fabric.js on heroku. I have done all the steps required for deploying a simple angular 6 app and the simple app worked. But, with fabricjs, it does not.
Here is the package.json file
{
"name": "projname",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build -prod"
},
"private": true,
"dependencies": {
"#angular/animations": "^6.1.10",
"#angular/cdk": "^6.4.7",
"#angular/common": "^6.1.0",
"#angular/compiler": "^6.1.0",
"#angular/core": "^6.1.0",
"#angular/forms": "^6.1.0",
"#angular/http": "^6.1.0",
"#angular/material": "^6.4.7",
"#angular/platform-browser": "^6.1.0",
"#angular/platform-browser-dynamic": "^6.1.0",
"#angular/router": "^6.1.0",
"angular-froala-wysiwyg": "^2.8.5",
"core-js": "^2.5.4",
"express": "^4.16.4",
"fabric": "^2.4.1",
"path": "^0.12.7",
"rxjs": "~6.2.0",
"typescript": "~2.9.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.8.0",
"#angular/cli": "^6.2.5",
"#angular/compiler-cli": "^6.1.10",
"#angular/language-service": "^6.1.0",
"#types/fabric": "^1.5.43",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"enhanced-resolve": "^3.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"surge": "^0.20.1",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
},
"engines": {
"node": "8.9.4",
"npm": "5.6.0"
}
}
All the required dependencies for a simple angular 6 app have been done. The server has also been set up. Here is the server.js file.
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist/projname'));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname + '/dist/projname/index.html'));
});
// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);
And, lastly here is the output. I think there is some problem with the node_module canvas. Thanks.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 8.9.4
engines.npm (package.json): 5.6.0
Resolving node version 8.9.4...
Downloading and installing node 8.9.4...
npm 5.6.0 already installed with node
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Building dependencies
Installing node modules (package.json + package-lock)
> canvas#1.6.12 install /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/canvas
> node-gyp rebuild
make: Entering directory '/tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/canvas/build'
SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
COPY Release/canvas-postbuild.node
CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:20:0:
../src/JPEGStream.h: In function ‘boolean empty_closure_output_buffer(j_compress_ptr)’:
../src/JPEGStream.h:42:108: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)dest->closure->fn, 2, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
In file included from ../src/Canvas.cc:20:0:
../src/JPEGStream.h: In function ‘void term_closure_destination(j_compress_ptr)’:
../src/JPEGStream.h:63:113: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)dest->closure->fn, 2, data_argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
In file included from ../src/Canvas.cc:20:0:
../src/JPEGStream.h:71:112: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)dest->closure->fn, 2, end_argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
../src/Canvas.cc: In static member function ‘static void Canvas::ToBufferAsyncAfter(uv_work_t*)’:
../src/Canvas.cc:221:31: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
closure->pfn->Call(1, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:1655:3: note: declared here
Call(int argc, v8::Local<v8::Value> argv[]) const {
^~~~
../src/Canvas.cc:226:31: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
closure->pfn->Call(2, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:1655:3: note: declared here
Call(int argc, v8::Local<v8::Value> argv[]) const {
^~~~
../src/Canvas.cc: In function ‘cairo_status_t streamPNG(void*, const uint8_t*, unsigned int)’:
../src/Canvas.cc:377:102: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)closure->fn, 3, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
../src/Canvas.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Canvas::StreamPNGSync(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/Canvas.cc:446:103: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)closure.fn, 1, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
../src/Canvas.cc:452:103: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), (v8::Local<v8::Function>)closure.fn, 1, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
../src/Canvas.cc: In function ‘cairo_status_t streamPDF(void*, const uint8_t*, unsigned int)’:
../src/Canvas.cc:476:77: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), closure->fn, 3, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Canvas.cc:7:
../../nan/nan.h:958:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
In file included from ../src/Canvas.cc:8:0:
../src/PNG.h: In function ‘cairo_status_t canvas_write_png(cairo_surface_t*, png_rw_ptr, void*)’:
../src/PNG.h:73:20: warning: variable ‘status’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
cairo_status_t status = CAIRO_STATUS_SUCCESS;
^~~~~~
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
CXX(target) Release/obj.target/canvas/src/color.o
CXX(target) Release/obj.target/canvas/src/Image.o
../src/Image.cc: In member function ‘void Image::loaded()’:
../src/Image.cc:380:25: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
onload->Call(0, NULL);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Image.cc:7:
../../nan/nan.h:1655:3: note: declared here
Call(int argc, v8::Local<v8::Value> argv[]) const {
^~~~
../src/Image.cc: In member function ‘void Image::error(v8::Local<v8::Value>)’:
../src/Image.cc:393:26: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
onerror->Call(1, argv);
^
In file included from ../src/Canvas.h:22:0,
from ../src/Image.cc:7:
../../nan/nan.h:1655:3: note: declared here
Call(int argc, v8::Local<v8::Value> argv[]) const {
^~~~
CXX(target) Release/obj.target/canvas/src/ImageData.o
CXX(target) Release/obj.target/canvas/src/init.o
CXX(target) Release/obj.target/canvas/src/FontFace.o
SOLINK_MODULE(target) Release/obj.target/canvas.node
COPY Release/canvas.node
make: Leaving directory '/tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/canvas/build'
> node-sass#4.9.3 install /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.3/linux-x64-57_binding.node
Download complete
Binary saved to /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /tmp/npmcache.Ba6aC/node-sass/4.9.3/linux-x64-57_binding.node
> circular-json#0.5.7 postinstall /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/circular-json
> echo ''; echo "\x1B[1mCircularJSON\x1B[0m is in \x1B[4mmaintenance only\x1B[0m, \x1B[1mflatted\x1B[0m is its successor."; echo ''
\x1B[1mCircularJSON\x1B[0m is in \x1B[4mmaintenance only\x1B[0m, \x1B[1mflatted\x1B[0m is its successor.
> node-sass#4.9.3 postinstall /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_2bdbd84339a09d50e7de179986c6e0f3/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
> bimscoper#0.0.0 postinstall /tmp/build_2bdbd84339a09d50e7de179986c6e0f3
> ng build -prod
Unknown option: '-p'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bimscoper#0.0.0 postinstall: `ng build -prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bimscoper#0.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.Ba6aC/_logs/2018-10-18T18_42_10_164Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed

Hey do you resolved your issue ?
Did you simply try add the link cdn or fabric project <script src="./assets/fabric.js"></script> in asset to your index on the angular project ?
after imports, declare fabric as any
declare const fabric: any;
Use it in AfterViewInit in your component and move fabric initialization into ngAfterViewInit event handler
ngAfterViewInit() {
const canvas = new fabric.Canvas('canvas');
const rect = new fabric.Rect({
top : 100,
left : 100,
width : 60,
height : 70,
fill : 'red'
});
canvas.add(rect);
}

Related

Unknown word error building a Chrome Extension using Laravel-mix with vue3

I'm in the process of building a chrome-extension manifest Version3 in vue.js 3 using laravel-mix. In order to prevent styles leaking between the extension code and the current browser tab, I've loaded the content-scripts code into a shadow-dom element. This is working however as the default compiling process from laravel-mix is to add the styles in a style tag in the head of the document, currently the css styling is being prevented from reaching the very place it should be isolated to. I've tried following the laravel-mix documentation that suggests using a function that lazy loads the style tag within the shadow dom element however I am getting this error and cannot work out what is wrong - guessing there is missing configs. Thanks in advance for any help.
Error Details
ERROR in ./src/assets/css/content_shinego.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js):
SyntaxError
(4:7) C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\src\assets\css\content_shinego.css Unknown word
2 | var exported = {};
3 |
4 | import API from "!../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
| ^
5 | import domAPI from "!../../../node_modules/style-loader/dist/runtime/styleDomAPI.js";
6 |
at processResult (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\webpack\lib\NormalModule.js:758:19)
at C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\webpack\lib\NormalModule.js:860:5
at C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\loader-runner\lib\LoaderRunner.js:400:11
at C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\loader-runner\lib\LoaderRunner.js:252:18
at context.callback (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
at Object.loader (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\laravel-mix\node_modules\postcss-loader\dist\index.js:140:7)
ERROR in ./src/assets/css/popup_shinego.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js):
SyntaxError
(4:7) C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\src\assets\css\popup_shinego.css Unknown word
2 | var exported = {};
3 |
4 | import API from "!../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
| ^
5 | import domAPI from "!../../../node_modules/style-loader/dist/runtime/styleDomAPI.js";
6 |
at processResult (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\webpack\lib\NormalModule.js:758:19)
Capture\draft\node_modules\loader-runner\lib\LoaderRunner.js:400:11 at C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\loader-runner\lib\LoaderRunner.js:252:18 at context.callback (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\loader-runner\lib\LoaderRunner.js:124:13) at Object.loader (C:\Users\ollie\Documents\Shine\ChromeExtensionScreenCapture\draft\node_modules\laravel-mix\node_modules\postcss-loader\dist\index.js:140:7)
2 ERRORS in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 4 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yobi-chrome#0.1.0 local: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --env=local --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yobi-chrome#0.1.0 local script.
npm ERR! C:\Users\ollie\AppData\Roaming\npm-cache_logs\2022-08-30T10_09_41_700Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yobi-chrome#0.1.0 dev: npm run local
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yobi-chrome#0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ollie\AppData\Roaming\npm-cache_logs\2022-08-30T10_09_41_718Z-debug.log
webpack.mix.js file
let mix = require('laravel-mix')
let path = require('path')
mix.setPublicPath('./')
mix.alias({
'#': path.join(__dirname, 'src')
});
mix.css('src/assets/css/content_shinego.css', 'dist/assets/css')
.css('src/assets/css/popup_shinego.css', 'dist/assets/css')
.css('src/assets/css/font-awesome.min.css', 'dist/assets/css')
.css('src/assets/css/mdbvue.css', 'dist/assets/css')
mix.js('src/popup/popup.js', 'dist/popup')
.js('src/content_scripts/content.js', 'dist/content_scripts')
.vue();
mix.copy('src/manifest.json', 'dist/')
.copy('src/background.js', 'dist/')
.copy('./css-loader-shim.js', 'dist/')
.copy('src/popup/popup.html', 'dist/popup')
.copy('src/assets/img/', 'dist/assets/img')
.copy('src/assets/icons/', 'dist/assets/icons')
.options({
processCssUrls: false
})
mix.webpackConfig({
module: {
rules: [
{
test: /\_shinego.css$/,
include: path.resolve(__dirname, 'src/assets/css'),
use: [
{
loader: "style-loader",
options: {
injectType: "lazyStyleTag",
insert: function insertIntoTarget(element, options) {
var parent = options.target || document.head;
parent.appendChild(element);
}
},
}
],
}
]
}
});
** Relevant package.json **
"dependencies": {
"#fortawesome/vue-fontawesome": "^2.0.8",
"axios": "^0.27.2",
"bootstrap-vue": "^2.22.0",
"fibers": "^5.0.2",
"fontawesome-free": "^1.0.4",
"lodash": "^4.17.21",
"mdb-vue-ui-kit": "^2.0.0",
"mdbvue": "git+https://oauth2:***#git.mdbootstrap.com/mdb/vue/vu-pro.git",
"postcss-loader": "^7.0.1",
"sass": "^1.54.4",
"vue-shadow-dom": "^4.2.0"
},
"devDependencies": {
"#types/chrome": "^0.0.194",
"#types/webpack-env": "^1.18.0",
"#vue/compiler-sfc": "^3.2.37",
"cross-env": "^7.0.3",
"laravel-mix": "^6.0.49",
"style-loader": "^3.3.1",
"types": "^0.1.1",
"vue": "^3.2.37",
"vue-loader": "^16.8.3",
"vue-template-compiler": "^2.7.9",
"webpack": "^5.74.0"
}

Discord Bot and Heroku

Hi I need some help with my discord bot. I searched up the errors and tried to fix it, but it just doesn’t work. It could have been a coding error on my end. PLEASE HELP and Thanks!
Link for the GitHub repository:
https://github.com/Verggz/Electrolite
Edit: errors that keep occuring
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2022-01-23T15:14:15.475287+00:00 app[worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2022-01-23T15:14:15.476783+00:00 app[worker.1]: /app/main.ts:1
2022-01-23T15:14:15.476784+00:00 app[worker.1]: import express from 'express';
2022-01-23T15:14:15.476785+00:00 app[worker.1]: ^^^^^^
2022-01-23T15:14:15.476785+00:00 app[worker.1]:
2022-01-23T15:14:15.476785+00:00 app[worker.1]: SyntaxError: Cannot use import statement outside a module
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2022-01-23T15:14:15.476788+00:00 app[worker.1]: at internal/main/run_main_module.js:17:47
package.json:
{
"name": "electrolite",
"version": "0.0.1",
"description": "literally just project scyll v2 but better",
"main": "./build/main.js",
"scripts": {
"start": "node --max-old-space-size=512 ./build/main.js && export NODE_ENV=production",
"dev": "tsc && node ./build/main.js",
"bot": "node ./build/bot/main.bot.js",
"botdev": "tsc && node ./build/bot/main.bot.js"
},
"keywords": [
"minecraft"
],
"author": "PenguinDetox",
"license": "ISC",
"dependencies": {
"#discordjs/builders": "^0.11.0",
"#discordjs/rest": "^0.2.0-canary.0",
"axios": "^0.24.0",
"discord-api-types": "^0.26.1",
"discord.js": "^13.5.0",
"express": "^4.17.2",
"fs-extra": "^10.0.0",
"hypixel-api-reborn": "^9.0.3",
"prismarine-nbt": "^2.0.0",
"set-interval-async": "^2.0.3"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#types/fs-extra": "^9.0.13",
"#types/node": "^17.0.4",
"#types/set-interval-async": "^1.0.0"
}
}
Procfile:
worker: node main.ts
I'm not totally sure what you're trying to do here, but the main issue at the moment is that you're asking Heroku to run your TypeScript code, not the compiled JavaScript. This is being done via your Procfile:
worker: node main.ts
You have a completely different command in your package.json:
"start": "node --max-old-space-size=512 ./build/main.js && export NODE_ENV=production",
This is probably closer to what you want, but we can't just use it like this.
The && export NODE_ENV part is unlikely to do anything useful: it will wait until your code stops running, then export an environment variable, then exit. Let's remove it:
"start": "node --max-old-space-size=512 ./build/main.js",
Now the issue is that build/main.js doesn't exist. You need to tell Heroku to build it during deployment. Based on your dev script, I believe that just involves running tsc.
Let's add a build script to do that:
"build": "tsc",
"start": "node --max-old-space-size=512 ./build/main.js",
(I don't see typescript in your devDependencies, which means tsc might fail to run. Make sure to include all dependencies in your package.json.)
Okay, so your build script will now tell Heroku to build your application during deployment and your build/main.js should exist. Your start script has been updated.
Let's deal with your Procfile. Update it to match the new start script:
worker: node --max-old-space-size=512 ./build/main.js
Commit all those changes and redeploy.

Build error with Keystone v5 – #keystonejs/app-next with Heroku CLI

I'm having issues trying to upload a website using this Keystone v5 + Next.js and everything runs well at dev and even builds locally: Styled-components + Styled-system, SSR and .babelrc (for styled-components config), also next.config.js (for jsconfig.json). But at the time that I do this line of code, using Heroku CLI it chash after everything upload
command line
git push heroku develop:master
doing it that way due I'm testing at develop branch from origin repo.
Heroku log
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: YARN_PRODUCTION=true
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 12.12.0
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): 1.22.4
remote:
remote: Resolving node version 12.12.0...
remote: Downloading and installing node 12.12.0...
remote: Using default npm version: 6.11.3
remote: Resolving yarn version 1.22.4...
remote: Downloading and installing yarn (1.22.4)...
remote: Installed yarn 1.22.4
remote:
remote: -----> Installing dependencies
remote: Installing node modules (yarn.lock)
remote: yarn install v1.22.4
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: info fsevents#2.1.3: The platform "linux" is incompatible with this module.
remote: info "fsevents#2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
remote: info fsevents#1.2.13: The platform "linux" is incompatible with this module.
remote: info "fsevents#1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
remote: [3/4] Linking dependencies...
remote: warning " > graphql-tag#2.10.3" has unmet peer dependency "graphql#^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
remote: warning "#keystonejs/fields > #apollo/react-hooks#3.1.5" has unmet peer dependency "#types/react#^16.8.0".
remote: warning "#keystonejs/fields > slate#0.47.9" has unmet peer dependency "immutable#>=3.8.1 || >4.0.0-rc".
remote: warning "#keystonejs/fields > slate-react#0.22.10" has unmet peer dependency "immutable#>=3.8.1 || >4.0.0-rc".
remote: warning "react-apollo > #apollo/react-common#3.1.4" has unmet peer dependency "#types/react#^16.8.0".
remote: warning "react-apollo > #apollo/react-common#3.1.4" has unmet peer dependency "apollo-utilities#^1.3.2".
remote: warning "react-apollo > #apollo/react-common#3.1.4" has unmet peer dependency "graphql#^14.3.1".
remote: warning " > apollo-cache-inmemory#1.6.6" has unmet peer dependency "graphql#^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning " > apollo-client#2.6.10" has unmet peer dependency "graphql#^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning "#keystonejs/apollo-helpers > apollo-link#1.2.14" has unmet peer dependency "graphql#^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning "#keystonejs/adapter-mongoose > #keystonejs/fields-mongoid > #keystonejs/fields > slate-react > react-immutable-proptypes#2.2.0" has unmet peer dependency "immutable#>=3.6.2".
remote: warning "#keystonejs/adapter-mongoose > #keystonejs/fields-mongoid > #keystonejs/fields > slate-react > slate-prop-types#0.5.44" has unmet peer dependency "immutable#>=3.8.1".
remote: warning "#keystonejs/apollo-helpers > apollo-cache#1.3.5" has unmet peer dependency "graphql#^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning "#keystonejs/apollo-helpers > apollo-utilities#1.3.4" has unmet peer dependency "graphql#^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning "#keystonejs/apollo-helpers > #apollo/react-components#3.1.5" has unmet peer dependency "graphql#^14.3.1".
remote: warning " > #keystonejs/app-graphql#5.1.7" has unmet peer dependency "express#^4.17.1".
remote: warning "#keystonejs/app-graphql > #keystonejs/app-graphql-playground#5.1.3" has unmet peer dependency "express#^4.17.1".
remote: warning " > apollo-link-http#1.5.17" has unmet peer dependency "graphql#^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
remote: warning "#keystonejs/app-graphql > #keystonejs/app-graphql-playground > #apollographql/graphql-playground-react > react-codemirror#1.0.0" has incorrect peer dependency "react#>=15.5 <16".
remote: warning "#keystonejs/app-graphql > #keystonejs/app-graphql-playground > #apollographql/graphql-playground-react > react-codemirror#1.0.0" has incorrect peer dependency "react-dom#>=15.5 <16".
remote: warning " > react-apollo#3.1.5" has unmet peer dependency "#types/react#^16.8.0".
remote: warning " > react-apollo#3.1.5" has unmet peer dependency "graphql#^14.3.1".
remote: warning "react-apollo > #apollo/react-hoc#3.1.5" has unmet peer dependency "#types/react#^16.8.0".
remote: warning "react-apollo > #apollo/react-hoc#3.1.5" has unmet peer dependency "graphql#^14.3.1".
remote: warning " > styled-components#5.1.1" has unmet peer dependency "react-is#>= 16.8.0".
remote: [4/4] Building fresh packages...
remote: Done in 92.86s.
remote:
remote: -----> Build
remote: Running build (yarn)
remote: yarn run v1.22.4
remote: $ cross-env NODE_ENV=production keystone build
remote: - Initialising Keystone CLI
remote: ℹ Command: keystone build
remote: -
remote: ✔ Validated project entry file ./index.js
remote: - Initialising Keystone instance
remote: ✔ Initialised Keystone instance
remote: - Exporting Keystone build to ./dist
**remote: warn - You have enabled experimental feature(s).
remote:
remote: warn - Experimental features are not covered by semver, and may cause** unexpected or broken application behavior. Use them at your own risk.
remote: Creating an optimized production build...
remote: Attention: Next.js now collects completely anonymous telemetry regarding usage.
remote: This information is used to shape Next.js' roadmap and prioritize features.
remote: You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
remote: https://nextjs.org/telemetry
remote:
remote: > Using external babel configuration
remote: > Location: "/tmp/build_a5f2f47908fc7f68e09dd51d79d5e3f7/app/.babelrc"
remote:
**remote: Failed to compile.
remote:
remote: ./pages/about-us.js
remote: Module not found: Can't resolve 'components/UI/layout' in '/tmp/build_a5f2f47908fc7f68e09dd51d79d5e3f7/app/pages'
remote:
remote: ✖ Exporting Keystone build to ./dist
remote: Error: > Build failed because of webpack errors
remote: at build (/tmp/build_a5f2f47908fc7f68e09dd51d79d5e3f7/node_modules/next/dist/build/index.js:13:917)**
remote: at async Promise.all (index 2)
remote: at async Object.exec (/tmp/build_a5f2f47908fc7f68e09dd51d79d5e3f7/node_modules/#keystonejs/keystone/bin/commands/build.js:42:7)
remote: error Command failed with exit code 1.
remote: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to xxxx.
remote:
Yes, I do know that it could be a webpack config error and I don't know what does mean about experimental feature.
keystone.js
const { Keystone } = require('#keystonejs/keystone');
const { PasswordAuthStrategy } = require('#keystonejs/auth-password');
const { GraphQLApp } = require('#keystonejs/app-graphql');
const { AdminUIApp } = require('#keystonejs/app-admin-ui');
const { NextApp } = require('#keystonejs/app-next');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
const { UserSchema } = require('./models');
const initialiseData = require('./initial-data');
const { MongooseAdapter: Adapter } = require('#keystonejs/adapter-mongoose');
const PROJECT_NAME = 'Website Name';
const adapterConfig = {
mongoUri: process.env.MONGO_URI,
useNewUrlParser: true,
useFindAndModify: false,
useUnifiedTopology: true,
};
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter(adapterConfig),
onConnect: process.env.CREATE_TABLES !== 'true' && initialiseData,
cookieSecret: 'long_secret',
cookie: {
secure: process.env.NODE_ENV === 'production',
maxAge: 1000 * 60 * 60 * 24 * 30,
sameSite: false,
},
secureCookies: false,
sessionStore: new MongoStore({
url: process.env.MONGO_URI,
autoReconnect: true,
secret: 'long_secret',
mongooseConnection: adapterConfig,
autoRemove: 'disabled'
})
});
keystone.createList('User', UserSchema);
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
module.exports = {
keystone,
apps: [
new GraphQLApp(),
new AdminUIApp({
enableDefaultRoute: false,
authStrategy,
}),
new NextApp({
dir: 'app',
})
],
configureExpress: app => {
app.set('trust proxy', 1);
}
};
I'm not pretty sure what I'm doing wrong, neither witch configuration do I need to do at next.config.js, since the only config that I have is this:
module.exports = {
experimental: {
jsconfigPaths: true,
}
}
with or without it, it gives me the same error, just the route changes and this error only occurs on pages folder
Folder Structure
./app
|– api/
|– apifile.js
|
|– components/
|– ...componentsfiles.js
|
|– hooks/
|– ...hooksfiles.js
|
|– pages/
|– ...pagesfiles.js
|
|– public/
|– assets/
|
|– utils
|– style
|_
|– ...styles.js
|– ...otherutils.js
|
|– .babelrc
|
|– jsconfig.json
|
|– next.config.js
./models/
./index.js (keystone.js)
./initial-data.js
./package.json
and this is my package.json file
{
"name": "xxxx-xxxx",
"description": "xxxx xxxx",
"private": true,
"version": "5.0.7",
"author": "Andler Develops",
"repository": "https://github.com/keystonejs/keystone/tree/master/packages/create-keystone-app/example-projects/starter",
"homepage": "https://github.com/keystonejs/keystone",
"license": "MIT",
"engines": {
"node": "12.12.0",
"yarn": "1.22.4"
},
"scripts": {
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start",
"create-tables": "cross-env CREATE_TABLES=true keystone create-tables"
},
"dependencies": {
"#keystonejs/adapter-mongoose": "^8.1.0",
"#keystonejs/apollo-helpers": "^5.1.4",
"#keystonejs/app-admin-ui": "^6.0.0",
"#keystonejs/app-graphql": "^5.1.7",
"#keystonejs/app-next": "^5.1.2",
"#keystonejs/auth-password": "^5.1.7",
"#keystonejs/field-content": "^6.0.1",
"#keystonejs/fields": "^10.0.0",
"#keystonejs/file-adapters": "^6.0.2",
"#keystonejs/keystone": "^9.0.0",
"#material-ui/core": "^4.10.0",
"#material-ui/lab": "^4.0.0-alpha.54",
"#styled-system/theme-get": "^5.1.2",
"aos": "^2.3.4",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"connect-mongo": "^3.2.0",
"cross-env": "^7.0.2",
"dotenv": "^8.2.0",
"envy": "^2.0.0",
"express-session": "^1.17.1",
"framer-motion": "^1.11.0",
"graphql-tag": "^2.10.3",
"next": "^9.4.4",
"react": "^16.13.1",
"react-apollo": "^3.1.5",
"react-dom": "^16.13.1",
"react-helmet": "^6.0.0",
"react-icons": "^3.10.0",
"react-lazy-load-image-component": "^1.5.0-beta.0",
"rebass": "^4.0.7",
"slugify": "^1.4.0",
"styled-components": "^5.1.1",
"styled-system": "^5.1.5"
},
"devDependencies": {
"babel-plugin-styled-components": "^1.10.7",
"prettier": "2.0.5"
}
}
I ran into this yesterday, it works locally, but when I deploy it does not and I get the error you're getting. I fixed it by moving my dependencies from my nextjs package.json, to the keystone package.json in the root of my project. I completely deleted my node_modules in the nextjs folder as I guess it just doesn't look at it.
I also didn't have problems on my local machine, but when built in a docker container received the error. I changed versions of the core packages to the ones in the beginner's guide:
"next": "9.3.5",
"react": "16.13.1",
"react-dom": "16.13.1",
I don't know why, but it helped. I lost more than 4 hours debugging this sh**...

Unable to use Elixir after upgrade

I upgraded my Elixir version from 3.0 to 5.0. The npm update command runs fine but when I try to run gulp --production it fails.
I have given the error below which I get.
My package.json file (which should be identical to the one at https://github.com/laravel/laravel/blob/master/package.json)
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.3.0"
}
}
When running gulp --production I get the below error
/home/vagrant/Code/laravel/node_modules/laravel- elixir/node_modules/gulp- cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157
this.processing = new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at LazyResult.async (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:79:21)
at Transform.stream._transform (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/index.js:27:17)
at Transform._read (_stream_transform.js:179:10)
at Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Transform.Writable.write (_stream_writable.js:183:11)
at write (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
You need to upgrade Node also.
You can read here how it can be updated upgraded: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

Grunt fails trying to load an empty module

I'm a bit stuck with my Jenkins setup on OSX Lion 10.7.3.
I'm using Grunt in my webapp to run Jasmine tests, build less, create cache manifest etc. Everything works on my laptop Lion 10.7.5, but on the server box grunt fails from time to time with the following error:
$ grunt less
module.js:340
throw err;
^
Error: Cannot find module ''
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:3)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at Process._handle.onexit (child_process.js:678:10)
This is intermittent, it fails approximately once out of five runs and is not task specific. It fails with the same rate when running grunt manifest or grunt test.
Once thing I noticed is that when it works it takes a second or two until the task starts executing, but when it fails it fails immediately.
I tried to remove node_modules, npm cache clear, reinstalling grunt-cli. Nothing works.
Here's my package.json:
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-contrib-copy": "0.4.0rc7",
"grunt-contrib-concat": "0.1.2rc6",
"grunt-contrib-coffee": "0.4.0rc7",
"grunt-contrib-uglify": "0.1.1rc6",
"grunt-contrib-compass": "0.1.1rc8",
"grunt-contrib-jshint": "0.1.1rc6",
"grunt-contrib-mincss": "0.4.0rc7",
"grunt-contrib-connect": "0.1.1rc6",
"grunt-contrib-clean": "0.4.0rc6",
"grunt-contrib-htmlmin": "0.1.1rc7",
"grunt-contrib-imagemin": "0.1.1rc8",
"grunt-contrib-livereload": "0.1.0rc8",
"grunt-contrib-jasmine": "~0.3.2",
"grunt-contrib-less": "0.5.0",
"grunt-manifest": "0.4.0",
"grunt-jslint": "0.2.5",
"grunt-bower-hooks": "~0.2.0",
"grunt-usemin": "~0.1.7",
"grunt-regarde": "~0.1.1",
"grunt-requirejs": "~0.3.1",
"grunt-mocha": "~0.2.2",
"grunt-open": "~0.1.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
npm and node versions:
$ npm -version
1.2.11
$ node --version
v0.8.20
I have now stripped down both packages.json and Gruntile.js:
$ cat package.json
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-manifest": "0.4.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
$ cat Gruntfile.js
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
manifest: {
generate: {
options: {
basePath: 'app/',
exclude: ['js/lib/amp/com.vaultus.api.WebApiAggregated.cache.js', 'js/lib/amp/com.vaultus.api.DebugWebApiAggregated.cache.js'],
timestamp: true
},
src: [
'index-hybrid.html',
'*.xml',
'js/**/*.js',
'css/**/*.css',
'css/images/**/*',
'i18n/**/*.js',
'template/**/*.html'
],
dest: 'app/cache-manifest.mf'
}
}
});
grunt.registerTask('build', [
'manifest'
]);
grunt.registerTask('default', ['build']);
};
No luck :(
We were hitting this issue on our CI builds.
After a bit of digging it looks like this was a bug in grunt-cli 0.1.6 and has been fixed in 0.1.7 of grunt-cli.

Resources