I have followed steps in https://www.botreetechnologies.com/blog/test-rails-app-using-mocha-js-chai-js to setup konacha.
I wrote a simple hello world test as follows in spec/javascripts folder:
var assert = require('assert');
describe('HelloWorld Module', function() {
it('should return -1 when "Hello" is missing', function() {
assert.equal(-1, "Hallo World".indexOf("Hello"));
});
it('should return 0 when sentence starts with Hello', function() {
assert.equal(0, "Hello World, how are you?".indexOf("Hello"));
});
});
when I run $bundle exec rake konacha:run --trace, it gives the following error:
rake aborted!
Don't know how to build task 'konacha:run' (see --tasks)
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/task_manager.rb:71:in `[]'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:151:in `invoke_task'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/bin/rake:23:in `load'
/home/vagrant/.rbenv/versions/2.2.10/bin/rake:23:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/exe/bundle:30:in `block in <top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/exe/bundle:22:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/bin/bundle:23:in `load'
/home/vagrant/.rbenv/versions/2.2.10/bin/bundle:23:in `<main>'
Could someone please help me with this.
I had to include the gem not just in the :test group of the gemfile but also in the :development group. It seemed to work after that.
Related
I am newbie on Jest and I have the following issue when I execute the command
npm test
I have the following files
functions.js
const functions = {
add: (num1,num2) => num1 + num2
};
module.exports = functions;
and the functions.test.js
const functions = require('./functions');
test(`Adds 2 + 2 to equal 4`, ()=>{
expect(functions.add(2,2)).toBe(4);
});
my package.json has the following context
{
"name": "jest-tutorial",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^29.2.2"
}
}
I havent found a lot of resources on the internet regarding the error I just try to remove the dot (.) character from the node_modules/jest
and the output of the console (error) is below
> jest-tutorial#1.0.0 test
> jest
C:\Users\agiallelis\node_modules\jest-cli\build\run.js:129
if (error?.stack) {
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\agiallelis\node_modules\jest-cli\build\index.js:12:12)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
I solved this during the writing of the question and have provided my answer below since it was a bit tricky to work out. I am happy to hear any better or alternative answers.
I have an Angular OpenLayers 6 geomapping app. Being Angular I use Typescript and it transpiles and runs fine. And also being Angular it uses ng test to do the testing. All tests run fine.
However I use mocha + chai for testing in the IDE (IntelliJ) since I don't require UI testing for the mathematical work I'm currently performing (ng test runs the UI tests if and when I need that. But in the IDE I select the tests to run). Testing this way worked fine until I added a new test that creates a new instance of a class that imports GeoJSON:
import GeoJSON from 'ol/format/GeoJSON';
That test fails (in mocha) with:
/home/smx9b6/dev/ng-eow/node_modules/ol/format/GeoJSON.js:17
import { assert } from '../asserts.js';
^
SyntaxError: Unexpected token {
Looking at the GeoJSON.js file it seems to have UMD module format (i think this is UMD):
/**
* #module ol/format/GeoJSON
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { assert } from '../asserts.js';
import Feature from '../Feature.js';
var GeoJSON = /** #class */ (function (_super) {
__extends(GeoJSON, _super);
/**
* #param {Options=} opt_options Options.
*/
function GeoJSON(opt_options) {
...
}
GeoJSON.prototype.writeGeometryObject = function (geometry, opt_options) {
return writeGeometry(geometry, this.adaptOptions(opt_options));
};
return GeoJSON;
}(JSONFeature));
And others, such as turf.js use the ES6 module format. eg. line-to-polygon:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bbox_1 = require("#turf/bbox");
var invariant_1 = require("#turf/invariant");
var helpers_1 = require("#turf/helpers");
...
function lineToPolygon(lines, options) {
if (options === void 0) { options = {}; }
...
}
...
exports.default = lineToPolygon;
Mocha can't deal with this but Angular can - I don't know why. I run mocha with (as reported by IntelliJ when running the test - full paths removed):
node node_modules/mocha/bin/_mocha --require ts-node/register --ui bdd --reporter mochaIntellijReporter.js
src/app/geometry-ops.spec.ts --grep "^geometry-ops centroid "
I have commonjs set as the module type:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [],
"resolveJsonModule": true,
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
...
}
The error in full is:
/home/smx9b6/dev/ng-eow/node_modules/ol/format/GeoJSON.js:17
import { assert } from '../asserts.js';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/src/app/layers-geometries.ts:4:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/src/app/geometry-ops.spec.ts:13:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:334:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:331:14)
at Mocha.run (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:809:10)
at Object.exports.singleRun (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run-helpers.js:108:16)
at exports.runMocha (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run-helpers.js:142:13)
at Object.exports.handler.argv [as handler] (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run.js:292:3)
at Object.runCommand (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/lib/command.js:242:26)
at Object.parseArgs [as _parseArgs] (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/yargs.js:1087:28)
at Object.parse (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/cli.js:68:6)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
I worked out and provide an answer below. However I would still like to hear any feedback on this. Such as should OpenLayers change their module format? (I'm still getting my head around all the different module formats).
The answer is to add --require esm --require jsdom-global/register to the node / mocha call.
The esm is to specify ES6 as the module format and jsdom-global is to define the DOM in non-browser environments (specifically to define document).
The full command is:
node node_modules/mocha/bin/_mocha --ui bdd \
--require ts-node/register \
--require esm \
--require jsdom-global/register \
--reporter landing \
src/app/geometry-ops.spec.ts --grep "^geometry-ops centroid "
(I added spaces in the command since it irks me when I have to scroll right to see such things).
I am happy to hear any better or alternative answers.
I am trying to deploy my application on Heroku, but it is showing following error
"We're sorry, but something went wrong."
So I've check my heroku logs, here is 2 problems I have
2019-05-22T13:56:04.512197+00:00 heroku[router]: at=info method=GET path="/" host=concierge-at-sea.herokuapp.com request_id=4f5fe5ef-ab45-4012-97be-87de88b8fdb5 fwd="89.95.71.184" dyno=web.1 connect=0ms service=1496ms status=500 bytes=1827 protocol=https
2019-05-22T13:55:35.566494+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-22T13:55:35.686117+00:00 heroku[web.1]: Process exited with status 143
This is for an app with devise, I've already tried heroku restart in order to restart my dyno's
But I don't understand the error 500, in local everything works
Here is my heroku logs
2019-05-22T13:53:09.716085+00:00 app[web.1]: ],
2019-05-22T13:53:09.716086+00:00 app[web.1]: "js.map": [
2019-05-22T13:53:09.716087+00:00 app[web.1]: "/packs/js/application-b9d827093751ba55443e.js.map"
2019-05-22T13:53:09.716089+00:00 app[web.1]: ]
2019-05-22T13:53:09.716090+00:00 app[web.1]: },
2019-05-22T13:53:09.716091+00:00 app[web.1]: "map": {
2019-05-22T13:53:09.716093+00:00 app[web.1]: "css": [
2019-05-22T13:53:09.716094+00:00 app[web.1]: "/packs/css/map-1c42ce8f.css"
2019-05-22T13:53:09.716096+00:00 app[web.1]: ],
2019-05-22T13:53:09.716097+00:00 app[web.1]: "js": [
2019-05-22T13:53:09.716098+00:00 app[web.1]: "/packs/js/map-c76722abf103111664a2.js"
2019-05-22T13:53:09.716100+00:00 app[web.1]: ],
2019-05-22T13:53:09.716101+00:00 app[web.1]: "js.map": [
2019-05-22T13:53:09.716102+00:00 app[web.1]: "/packs/js/map-c76722abf103111664a2.js.map"
2019-05-22T13:53:09.716104+00:00 app[web.1]: ]
2019-05-22T13:53:09.716105+00:00 app[web.1]: }
2019-05-22T13:53:09.716106+00:00 app[web.1]: },
2019-05-22T13:53:09.716108+00:00 app[web.1]: "map.css": "/packs/css/map-1c42ce8f.css",
2019-05-22T13:53:09.716109+00:00 app[web.1]: "map.js": "/packs/js/map-c76722abf103111664a2.js",
2019-05-22T13:53:09.716110+00:00 app[web.1]: "map.js.map": "/packs/js/map-c76722abf103111664a2.js.map"
2019-05-22T13:53:09.716112+00:00 app[web.1]: }
2019-05-22T13:53:09.716113+00:00 app[web.1]: ):
2019-05-22T13:53:09.716334+00:00 app[web.1]: F, [2019-05-22T13:53:09.716276 #4] FATAL -- : [20ca8723-7451-41e8-ab0d-df5b3e56c777] 7: <%= csrf_meta_tags %>
2019-05-22T13:53:09.716337+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 8: <%= action_cable_meta_tag %>
2019-05-22T13:53:09.716338+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 9: <%= stylesheet_link_tag 'application', media: 'all' %>
2019-05-22T13:53:09.716340+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 10: <%= stylesheet_pack_tag 'application', media: 'all' %>
2019-05-22T13:53:09.716341+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 11: <%= stylesheet_pack_tag 'map' %>
2019-05-22T13:53:09.716343+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 12: </head>
2019-05-22T13:53:09.716344+00:00 app[web.1]: [20ca8723-7451-41e8-ab0d-df5b3e56c777] 13: <body>
2019-05-22T13:53:09.716426+00:00 app[web.1]: F, [2019-05-22T13:53:09.716369 #4] FATAL -- : [20ca8723-7451-41e8-ab0d-df5b3e56c777]
2019-05-22T13:53:09.716517+00:00 app[web.1]: F, [2019-05-22T13:53:09.716463 #4] FATAL -- : [20ca8723-7451-41e8-ab0d-df5b3e56c777] app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb___4054649697818533831_47054766793720'
2019-05-22T13:55:34.396458+00:00 heroku[web.1]: Restarting
2019-05-22T13:55:34.681019+00:00 heroku[web.1]: State changed from up to starting
2019-05-22T13:55:35.566494+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-22T13:55:35.686117+00:00 heroku[web.1]: Process exited with status 143
2019-05-22T13:55:35.579278+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2019-05-22T13:55:35.582846+00:00 app[web.1]: === puma shutdown: 2019-05-22 13:55:35 +0000 ===
2019-05-22T13:55:35.582878+00:00 app[web.1]: - Goodbye!
2019-05-22T13:55:41.287394+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2019-05-22T13:55:43.390424+00:00 app[web.1]: Puma starting in single mode...
2019-05-22T13:55:43.390453+00:00 app[web.1]: * Version 3.12.1 (ruby 2.5.3-p105), codename: Llamas in Pajamas
2019-05-22T13:55:43.390455+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-22T13:55:43.390456+00:00 app[web.1]: * Environment: production
2019-05-22T13:55:45.981837+00:00 heroku[web.1]: State changed from starting to up
2019-05-22T13:55:45.842400+00:00 app[web.1]: * Listening on tcp://0.0.0.0:21575
2019-05-22T13:55:45.842712+00:00 app[web.1]: Use Ctrl-C to stop
2019-05-22T13:56:03.019885+00:00 app[web.1]: I, [2019-05-22T13:56:03.019766 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Started GET "/" for 89.95.71.184 at 2019-05-22 13:56:03 +0000
2019-05-22T13:56:03.021420+00:00 app[web.1]: I, [2019-05-22T13:56:03.021348 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Processing by Devise::SessionsController#new as HTML
2019-05-22T13:56:03.112359+00:00 app[web.1]: I, [2019-05-22T13:56:03.112174 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Rendering devise/sessions/new.html.erb within layouts/application
2019-05-22T13:56:04.512197+00:00 heroku[router]: at=info method=GET path="/" host=concierge-at-sea.herokuapp.com request_id=4f5fe5ef-ab45-4012-97be-87de88b8fdb5 fwd="89.95.71.184" dyno=web.1 connect=0ms service=1496ms status=500 bytes=1827 protocol=https
2019-05-22T13:56:04.509151+00:00 app[web.1]: I, [2019-05-22T13:56:04.509056 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Rendered devise/shared/_links.html.erb (1.1ms)
2019-05-22T13:56:04.509685+00:00 app[web.1]: I, [2019-05-22T13:56:04.509622 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Rendered devise/sessions/new.html.erb within layouts/application (1397.3ms)
2019-05-22T13:56:04.511523+00:00 app[web.1]: I, [2019-05-22T13:56:04.511465 #4] INFO -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] Completed 500 Internal Server Error in 1490ms (ActiveRecord: 17.4ms)
2019-05-22T13:56:04.512104+00:00 app[web.1]: F, [2019-05-22T13:56:04.512053 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5]
2019-05-22T13:56:04.512180+00:00 app[web.1]: F, [2019-05-22T13:56:04.512116 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] ActionView::Template::Error (Webpacker can't find application in /app/public/packs/manifest.json. Possible causes:
2019-05-22T13:56:04.512182+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2019-05-22T13:56:04.512183+00:00 app[web.1]: unless you are using the `webpack -w` or the webpack-dev-server.
2019-05-22T13:56:04.512184+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2019-05-22T13:56:04.512185+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2019-05-22T13:56:04.512186+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
2019-05-22T13:56:04.512188+00:00 app[web.1]: Your manifest contains:
2019-05-22T13:56:04.512189+00:00 app[web.1]: {
2019-05-22T13:56:04.512190+00:00 app[web.1]: "application.js": "/packs/js/application-b9d827093751ba55443e.js",
2019-05-22T13:56:04.512192+00:00 app[web.1]: "application.js.map": "/packs/js/application-b9d827093751ba55443e.js.map",
2019-05-22T13:56:04.512193+00:00 app[web.1]: "entrypoints": {
2019-05-22T13:56:04.512194+00:00 app[web.1]: "application": {
2019-05-22T13:56:04.512195+00:00 app[web.1]: "js": [
2019-05-22T13:56:04.512196+00:00 app[web.1]: "/packs/js/application-b9d827093751ba55443e.js"
2019-05-22T13:56:04.512197+00:00 app[web.1]: ],
2019-05-22T13:56:04.512198+00:00 app[web.1]: "js.map": [
2019-05-22T13:56:04.512199+00:00 app[web.1]: "/packs/js/application-b9d827093751ba55443e.js.map"
2019-05-22T13:56:04.512200+00:00 app[web.1]: ]
2019-05-22T13:56:04.512201+00:00 app[web.1]: },
2019-05-22T13:56:04.512202+00:00 app[web.1]: "map": {
2019-05-22T13:56:04.512203+00:00 app[web.1]: "css": [
2019-05-22T13:56:04.512204+00:00 app[web.1]: "/packs/css/map-1c42ce8f.css"
2019-05-22T13:56:04.512205+00:00 app[web.1]: ],
2019-05-22T13:56:04.512206+00:00 app[web.1]: "js": [
2019-05-22T13:56:04.512207+00:00 app[web.1]: "/packs/js/map-c76722abf103111664a2.js"
2019-05-22T13:56:04.512208+00:00 app[web.1]: ],
2019-05-22T13:56:04.512209+00:00 app[web.1]: "js.map": [
2019-05-22T13:56:04.512210+00:00 app[web.1]: "/packs/js/map-c76722abf103111664a2.js.map"
2019-05-22T13:56:04.512211+00:00 app[web.1]: ]
2019-05-22T13:56:04.512212+00:00 app[web.1]: }
2019-05-22T13:56:04.512213+00:00 app[web.1]: },
2019-05-22T13:56:04.512214+00:00 app[web.1]: "map.css": "/packs/css/map-1c42ce8f.css",
2019-05-22T13:56:04.512215+00:00 app[web.1]: "map.js": "/packs/js/map-c76722abf103111664a2.js",
2019-05-22T13:56:04.512217+00:00 app[web.1]: "map.js.map": "/packs/js/map-c76722abf103111664a2.js.map"
2019-05-22T13:56:04.512218+00:00 app[web.1]: }
2019-05-22T13:56:04.512219+00:00 app[web.1]: ):
2019-05-22T13:56:04.512299+00:00 app[web.1]: F, [2019-05-22T13:56:04.512257 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 7: <%= csrf_meta_tags %>
2019-05-22T13:56:04.512300+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 8: <%= action_cable_meta_tag %>
2019-05-22T13:56:04.512301+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 9: <%= stylesheet_link_tag 'application', media: 'all' %>
2019-05-22T13:56:04.512302+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 10: <%= stylesheet_pack_tag 'application', media: 'all' %>
2019-05-22T13:56:04.512303+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 11: <%= stylesheet_pack_tag 'map' %>
2019-05-22T13:56:04.512304+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 12: </head>
2019-05-22T13:56:04.512305+00:00 app[web.1]: [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] 13: <body>
2019-05-22T13:56:04.512334+00:00 app[web.1]: F, [2019-05-22T13:56:04.512299 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5]
2019-05-22T13:56:04.512374+00:00 app[web.1]: F, [2019-05-22T13:56:04.512340 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__246445882644024882_47273754121400'```
My routes
Rails.application.routes.draw do
devise_for :users
get '/dashboard' => 'pages#dashboard'
devise_scope :user do
root to: "devise/sessions#new"
end
authenticated :user do
root 'pages#dashboard'
end
end
My Layouts
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Concierge#Sea</title>
<%= csrf_meta_tags %>
<%= action_cable_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= stylesheet_pack_tag 'application', media: 'all' %>
<%= stylesheet_pack_tag 'map' %>
</head>
<body>
<%= render 'shared/flyout' %>
<%= render 'shared/navbar' %>
<%= render 'shared/flashes' %>
<%= yield %>
<%= javascript_include_tag 'application' %>
<%= javascript_pack_tag 'application' %>
<%= javascript_pack_tag 'map' %>
</body>
</html>
Thanks you if you can help me or give me any advice
From your heroku logs looks like you have issues with webpacker. As you can see here
2019-05-22T13:56:04.512104+00:00 app[web.1]: F, [2019-05-22T13:56:04.512053 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5]
2019-05-22T13:56:04.512180+00:00 app[web.1]: F, [2019-05-22T13:56:04.512116 #4] FATAL -- : [4f5fe5ef-ab45-4012-97be-87de88b8fdb5] ActionView::Template::Error (Webpacker can't find application in /app/public/packs/manifest.json. Possible causes:
2019-05-22T13:56:04.512182+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2019-05-22T13:56:04.512183+00:00 app[web.1]: unless you are using the `webpack -w` or the webpack-dev-server.
2019-05-22T13:56:04.512184+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2019-05-22T13:56:04.512185+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2019-05-22T13:56:04.512186+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
Did you run webpacker:compile command on heroku?
Also based on info here https://github.com/rails/webpacker/issues/1494. There may be an issue with webpacker itself.
I am using the serverless framework to develop lambda functions in the aws cloud. Currently, I am running into an issue when including a library that I made. It seems the recommended way to do this is to either:
1) npm install <path/to/your/lib>
2) npm link and related commands
In the first situation, when using npm install ../libs, and include the module using const Libs = require('libs') , the package appears to install correctly (it is listed in the package.json). However, on uploading the service to aws or using sls invoke local -f my-func the following error is thrown:
{ Error: Cannot find module 'libs'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:419:18)
at __webpack_require__ (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:20:30)
at Object.<anonymous> (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:376:16)
at __webpack_require__ (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:20:30)
at Object.defineProperty.value (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:63:18)
at Object.<anonymous> (/Users/Documents/GitHub/serverless-cloud-functions/dynamodb-stream-handlers/.webpack/service/service-provider-users-archive-stream-handler.js:66:10)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at AwsInvokeLocal.invokeLocalNodeJs (/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:258:33)
at AwsInvokeLocal.invokeLocal (/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:125:19)
at AwsInvokeLocal.tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:773:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate [as _immediateCallback] (timers.js:711:5) code: 'MODULE_NOT_FOUND' }
Using npm link gives similar results as well. I have a hunch that the issue has to do with the fact that I'm using babel and webpack, but I'm not sure.
Here is the contents of my webpack.config.js file:
const slsw = require("serverless-webpack");
const nodeExternals = require("webpack-node-externals");
module.exports = {
entry: slsw.lib.entries,
target: "node",
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
include: __dirname,
exclude: /node_modules/
}
]
},
};
Including the individual clients, instead of the overall lib seems to have solved the above error, but now I am faced with a new error.
Here is the serverless.yml file:
service: instant-response-api
plugins:
- serverless-webpack
- serverless-domain-manager
- serverless-plugin-aws-alerts
custom:
alerts:
topics:
alarm: ${file(./env.yml):${opt:stage}.ADMIN_SNS_TOPIC_ARN}
alarms:
- functionErrors
webpackIncludeModules: true
customDomain:
domainName: ${file(./env.yml):${opt:stage}.DOMAIN_NAME}
basepath: ''
stage: ${opt:stage}
createdRoute53Record: true
provider:
name: aws
runtime: nodejs6.10
region: us-west-2
stage: ${opt:stage}
environment:
${file(./env.yml):${opt:stage}}
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:DescribeTable
Resource: "arn:aws:dynamodb:us-west-2:*:*"
- Effect: "Allow"
Action:
- sns:Publish
- sns:CreateTopic
Resource: "arn:aws:sns:*:*:*"
functions:
create-service-provider-number:
handler: create-service-provider-number.main
memorySize: 3008
timeout: 30
logRetentionInDays: 30
events:
- http:
path: create-service-provider-number/{serviceProviderId}
method: post
cors: true
alarms:
- functionErrors
service-provider-sms-handler:
handler: service-provider-sms-handler.main
memorySize: 3008
timeout: 30
logRetentionInDays: 30
events:
- http:
path: service-provider-sms-handler/{serviceProviderId}
method: post
cors: true
alarms:
- functionErrors
end-user-voice-handler:
handler: end-user-voice-handler.main
memorySize: 3008
timeout: 30
logRetentionInDays: 30
events:
- http:
path: end-user-voice-handler/{userId}/{propertyId}
method: post
cors: true
alarms:
- functionErrors
end-user-sms-handler:
handler: end-user-sms-handler.main
memorySize: 3008
timeout: 30
logRetentionInDays: 30
events:
- http:
path: end-user-sms-handler/{userId}/{propertyId}
method: post
cors: true
alarms:
- functionErrors
And here is package.json:
{
"name": "instant-response-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"aws-sdk": "^2.177.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-3": "^6.24.1",,
"jest": "^22.4.2",
"jest-cli": "^22.1.4",,
"serverless-domain-manager": "^2.1.0",
"serverless-plugin-aws-alerts": "^1.2.4",
"serverless-webpack": "^4.2.0",
"webpack": "^3.10.0",
"webpack-node-externals": "^1.6.0"
},
"dependencies": {
"#google/maps": "^0.4.5",
"babel-runtime": "^6.26.0",
"query-string": "^5.0.1",
"twilioClient": "file:../libs/twilioClient",
"dynamodbClient": "file:../libs/dynamodbClient",
"snsClient": "file:../libs/snsClient"
}
}
My new error:
START RequestId: a9962b1d-21dd-11e8-bc1e-35d1e2dcfd8e Version: $LATEST
Syntax error in module 'service-provider-sms-handler': SyntaxError
async sendSms({to, from, msg}) {
^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
END RequestId: a9962b1d-21dd-11e8-bc1e-35d1e2dcfd8e
REPORT RequestId: a9962b1d-21dd-11e8-bc1e-35d1e2dcfd8e Duration: 5.62 ms Billed Duration: 100 ms Memory Size: 3008 MB Max Memory Used: 22 MB
I'm trying to deploy to Heroku and I am met with this error. I've done some research and tried uninstalling and reinstalling some gems after looking at relevant posts but I'm not really sure what's wrong here as I am not familiar with what the actual problem is. Please help! What should I do? So far I'm thinking it has something to do with the jquery.
ExecJS::ProgramError: Unexpected character '#' (line: 13912, col: 0, pos: 394110)
remote: Error
remote: at new JS_Parse_Error (/tmp/execjs20150204-1143-zrnj29js:2359:10623)
remote: at js_error (/tmp/execjs20150204-1143-zrnj29js:2359:10842)
remote: at parse_error (/tmp/execjs20150204-1143-zrnj29js:2359:12560)
remote: at Object.next_token [as input] (/tmp/execjs20150204-1143-zrnj29js:2359:17582)
remote: at next (/tmp/execjs20150204-1143-zrnj29js:2359:18900)
remote: at semicolon (/tmp/execjs20150204-1143-zrnj29js:2359:19745)
remote: at simple_statement (/tmp/execjs20150204-1143-zrnj29js:2359:22580)
remote: at /tmp/execjs20150204-1143-zrnj29js:2359:20708
remote: at /tmp/execjs20150204-1143-zrnj29js:2359:19957
remote: at /tmp/execjs20150204-1143-zrnj29js:2359:31968
remote: at Object.parse (/tmp/execjs20150204-1143-zrnj29js:2360:152)
remote: (in /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/app/assets/javascripts/application.js)/tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/execjs-2.2.2/lib/execjs/external_runtime.rb:64:in `extract_result'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/execjs-2.2.2/lib/execjs/external_runtime.rb:29:in `exec'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/uglifier-2.7.0/lib/uglifier.rb:200:in `run_uglifyjs'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/uglifier-2.7.0/lib/uglifier.rb:178:in `compile'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/uglifier_compressor.rb:25:in `evaluate'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:197:in `block in evaluate'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `each'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `evaluate'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/bundled_asset.rb:25:in `initialize'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `new'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `build_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:211:in `block in find_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:257:in `benchmark'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:210:in `find_asset'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:119:in `block in compile'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `each'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `compile'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.2.2/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/rake/sprocketstask.rb:146:in `with_logger'
remote: /tmp/build_eb6f5cb07cab440eb52a1d47cb70ca23/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.2.2/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
remote: Tasks: TOP => assets:precompile
remote: (See full trace by running task with --trace)
gem file
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bootstrap-sass', '~> 3.3.3'
gem 'autoprefixer-rails'
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
/welcome.js
(function($) {
var $container = $(".parallax");
var $divs = $container.find("div.parallax-background");
var thingBeingScrolled = document.body;
var liHeight = $divs.eq(0).closest("li").height();
var diffHeight = $divs.eq(0).height() - liHeight;
var i,len,li,offset,scroll,top;
var render = function() {
top = thingBeingScrolled.scrollTop;
//loop through divs
for(i=0,len=$divs.length;i<len;i++) {
//get one div
div = $divs[i];
//get the parent LI
li = div.parentNode;
//calculate the offsetTOP of the div
offset = $(div).offset().top
//calculate the amount to scroll
scroll = Math.round(((top - offset)/liHeight) * diffHeight);
//apply scroll amount
div.style.webkitTransform = "translate3d(0px,"+scroll+"px,0px)";
}
};
(function loop(){
requestAnimationFrame(loop);
render();
})();
})(jQuery);
remove the comment line which is start with "#" from any of your .js file