Sails.js swig template not working - javascript

I installed Sails.js 0.9.4 and created an application that uses the swig template engine with the following command:
sails new sailsproject--template=swig
When I try to run the app via sails lift I get the following error:
C:\Users\akis\Desktop\sailsproject>sails lift
C:\Users\akis\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\ap
plication.js:174
if ('function' != typeof fn) throw new Error('callback function required');
^
Error: callback function required
at Function.app.engine (C:\Users\akis\AppData\Roaming\npm\node_modules\sails
\node_modules\express\lib\application.js:174:38)
at Array.loadExpress [as 1] (C:\Users\akis\AppData\Roaming\npm\node_modules\
sails\lib\express\index.js:70:7)
at listener (C:\Users\akis\AppData\Roaming\npm\node_modules\sails\node_modul
es\async\lib\async.js:462:46)
at C:\Users\akis\AppData\Roaming\npm\node_modules\sails\node_modules\async\l
ib\async.js:416:17
at Array.forEach (native)
at _each (C:\Users\akis\AppData\Roaming\npm\node_modules\sails\node_modules\
async\lib\async.js:32:24)
at Object.taskComplete (C:\Users\akis\AppData\Roaming\npm\node_modules\sails
\node_modules\async\lib\async.js:415:13)
at processImmediate [as _immediateCallback] (timers.js:330:15)
C:\Users\akis\Desktop\sailsproject>
Does anyone know why? It works perfectly with jade or ejs and the docs in the /config/views.js file state that Sails supports other templates as well (including swig).

This is a bug that is fixed in the development branch of sails and should be fixed in the next release.
See: https://github.com/balderdashy/sails/issues/868

Related

Truffle '"Migrations" -- cb is not a function'

I wrote a simple smart contract in Solidity 0.6.6 that I'm trying to deploy to the BSC Testnet.
This is what I have in my truffle-config.js file (privateKeys is an array with a single entry of ['0x + privatekey']:
networks: {
bscTestnet: {
provider: () => new HDWalletProvider(
privateKeys,
'https://data-seed-prebsc-1-s1.binance.org:8545/'
),
network_id: 97,
skipDryRun: true
}
}
When I run the command "truffle migrate --reset --network bscTestnet" I get the following error:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'bscTestnet'
> Network id: 97
> Block gas limit: 30000000 (0x1c9c380)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- cb is not a function.
at /Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
at Migration._load (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
at Migration.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
at Object.runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
at Object.runFrom (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.runAll (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
at Object.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
at runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:80:1)
at Object.module.exports [as run] (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
at Command.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.31 (core: 5.4.31)
Node v17.4.0
Opened an Issue a about it: https://github.com/trufflesuite/truffle/issues/4676
I guess its a bug in HardwareWallet2.0.2.
Reverting to HardwareWallet2.0.0 solved the problem for me
npm i #truffle/hdwallet-provider#2.0.0
UPDATE:
Right, workaround: I rolled #HDWalletProvider back to v2.0.1 and was able to migrate.
I assume there must be an issue with the new version for ppl who updated today.
================
Same problem with Polygon Mumbai.
Function "cb" refers to the callback function. The strange part is the error message doesn't reference my own code at all; it references the migrations.js located in:
<.nvm/versions/node/v16.11.1/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at processTicksAndRejections (node:internal/process/task_queues:96:5>
This leads me to believe there's a problem with out 1_initial_migration.js... however that's auto-generated so I can't see any problem... it's strange.
1_initial_migration.js:
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};

Error while initializing app TypeError: parentVal.concat is not a function

I created a fresh Nuxt.js project: npx create-nuxt-app project
Then I launch the server: cd project && npm run dev
Till this point is all ok.
Now I want to install nuxt-i18n: npm i nuxt-i18n and then I added it in nuxt.config.js:
modules: [
['nuxt-i18n', {
// Options
}]
I am getting the following error in the console of the development tools (with a page showing blank):
app.js:455 [nuxt] Error while initializing app TypeError: parentVal.concat is not a function
at mergeHook (commons.app.js:11924)
at mergeField (commons.app.js:12185)
at mergeOptions (commons.app.js:12176)
at Vue._init (commons.app.js:15301)
at new Vue (commons.app.js:15419)
at _callee5$ (app.js:1317)
at tryCatch (commons.app.js:5854)
at Generator.invoke [as _invoke] (commons.app.js:6088)
at Generator.prototype.(:3000/anonymous function) [as next] (http://localhost:3000/_nuxt/commons.app.js:5906:21)
at asyncGeneratorStep (commons.app.js:33)
What causes this and how to fix it?
It seems due to a sub dependency issue from vue-meta used by vue-i18n
(see the open issue https://github.com/nuxt-community/nuxt-i18n/issues/127)
as workaround, try to set the seo option at false :
// nuxt.config.js
['nuxt-i18n', {
seo: false
}]
It was due to vue-meta. Vue-meta 1.5.5 was released that is fixed this issue.
So you can update it and it will fine

Circular references in Webpack build of kurento-client-js

I'm facing an error while trying to build kurento-client-js with Webpack 2 + babel.
WARNING in ./node_modules/kurento-client/lib/register.js
60:20-33 Critical dependency: the request of a dependency is an expression
On execution it results in
Uncaught Error: Cannot find module "."
I believe that the issue itself is сaused by require inside /lib/register.js
//kurento-clinet/lib/register.js
if (constructor == undefined)
return register(require(name));
And the code that cause errors:
//kurento-clinet/lib/index.js
//this module requires kurento-client resulting in circular reference
register('kurento-client-core')
The kurento bower package contains distributive built with the browserify.
I wonder if anyone tried to build kurento-client-js using webpack. Please share your experience.
EDIT:
Circular dependency error stack trace:
Uncaught TypeError: Cannot read property 'MediaObject' of undefined
at Object._typeof (KurentoClient.js:42)
at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19)
at Object._typeof (index.js:44)
at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19)
at Object.module.exports (HubPort.js:21)
at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19)
at Object._typeof (index.js:32)
at ...
First of all webpack complains about a dynamic dependency (which cannot be resolved when building the bundle). It's not a circular dependency.
I got it working like this:
1) in your app's main.js require manually all the modules which the register() function might need
require('kurento-client-core')
require('kurento-client-elements')
require('kurento-client-filters')
const kc = require('kurento-client-core/lib/index.js')
console.log(kc)
2) use this webpack plugin to completely ignore unresolved/dynamic require() calls
//in webpack.config.js
plugins:[
function() {
this.parser.plugin('call require', function(expr) {
if (expr.arguments.length !== 1) {
return;
}
const param = this.evaluateExpression(expr.arguments[0]);
if (!param.isString() && !param.isConditional()) {
return true;
}
});
}
//... other plugins
]
Webpack2 will warn about old plugin format, but it does work
Credits go to:
https://stackoverflow.com/a/42527120/646156

Getting "TypeError: Cannot read property 'filename' of undefined" when calling `npm start`

I am following this quite lengthy but very informative post about setting up a web application using the following technology stack:
es 6
node + express
handlebars
react + react router
webpack + babel
The sample code can be found here.
I have been following along and it went quite well, I did understand the most important concepts. However, I am getting an error when I am trying to run it (after I downloaded it using git clone) like so:
$ npm install
$ npm start
The generated output including the error is:
> react-ssr-example#0.0.1 start /Users/nburk/Developer/node/templates/react-universal-web-apps-simple
> npm-run-all --parallel gulp server
> react-ssr-example#0.0.1 server /Users/nburk/Developer/node/templates/react-universal-web-apps-simple
> node-dev app/babel-server.js
> react-ssr-example#0.0.1 gulp /Users/nburk/Developer/node/templates/react-universal-web-apps-simple
> gulp
[19:10:39] Using gulpfile ~/Developer/node/templates/react-universal-web-apps-simple/gulpfile.js
[19:10:39] Starting 'build:scss'...
[19:10:39] Starting 'build:watch:app'...
TypeError: Cannot read property 'filename' of undefined
at Object.obj.(anonymous function) [as runInThisContext] (/Users/nburk/Developer/node/templates/react-universal-web-apps-simple/node_modules/node-dev/lib/hook.js:25:55)
at Object.<anonymous> (/Users/nburk/Developer/node/templates/react-universal-web-apps-simple/node_modules/graceful-fs/fs.js:10:13)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at nodeDevHook (/Users/nburk/Developer/node/templates/react-universal-web-apps-simple/node_modules/node-dev/lib/hook.js:58:7)
at require.extensions.(anonymous function) (/Users/nburk/Developer/node/templates/react-universal-web-apps-simple/node_modules/babel-core/lib/api/register/node.js:214:7)
at Object.nodeDevHook [as .js] (/Users/nburk/Developer/node/templates/react-universal-web-apps-simple/node_modules/node-dev/lib/hook.js:58:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
[19:10:39] Finished 'build:watch:app' after 12 ms
[19:10:39] Starting 'lint:app'...
[ERROR] 19:10:39 TypeError
[19:10:39] Starting 'server'...
Does anyone see what I am missing? I have no clue where even to start, the filenames in the error don't really tell me anything...
Update
I checked for the file where the error occurs (/node_modules/node-dev/lib/hook.js), here's the code that causes it:
/**
* Patch the specified method to watch the file at the given argument
* index.
*/
function patch(obj, method, optionsArgIndex) {
var orig = obj[method];
if (!orig) return;
obj[method] = function () {
var opts = arguments[optionsArgIndex];
var file = typeof opts == 'string' ? opts : opts.filename;
if (file) callback(file);
return orig.apply(this, arguments);
};
}
You are getting that error because you are trying to access a property of a variable whose value is undefined. In your case, opts is getting the value undefined from var opts = arguments[optionsArgIndex]; this line and you cannot access a property of an undefined variable.
Wrap this up in try-catch or add checks before accessing nested properties of objects. It is generally considered a bad approach in JavaScript to access nested variables directly.
For example, instead of var a = b.c.d; you should use var a = (a && a.b && a.b.c) || <some default value>;
In the first case, if b or c is undefined, your app will crash, however, if b or c is undefined in the second case, a will be assigned the default value which you provided
You can solve this problem simply by explicitly force previous version of node-dev by doing this:
npm i node-dev#3.0.0 --save-dev
Fix#130 https://github.com/fgnass/node-dev/issues/130 brings some other mentioned by #rramakrishnaa bugs.

Sencha touch production build errors

Using touch 2.1.0 and Cmd 3.1.2.342
Whilst trying to create a production version of my sencha app, I get the following error:
[WRN] C1003: Unsupported Ext.define syntax -- C:\wamp\www\touch-2.1.0\axis\nativ
e\appname\touch\src\fx\TimingFunctions.js:109
[ERR] C2008: Requirement had no matching files (Ext.fx.TimingFunctions) -- C:\wa
mp\www\touch-2.1.0\axis\native\appname\touch\src\fx\Abstract.js:959
[ERR] The following error occurred while executing this line:
C:\wamp\www\touch-2.1.0\axis\native\appname.sencha\app\build-impl.xml:165:
It seems to me that it is saying a file called fx/TimingFunctions.js is required by fx/Abstract.js but cannot be found. However, this can't be what it means as the file exists in that folder.
The command I am using is:
sencha app build production
Line 109 of TimingFunctions.js looks like this:
Ext.define('Ext.fx.TimingFunctions', Ext.apply({
singleton: true,...
One solution is to change line 109 of TimingFunctions.js from:
Ext.define('Ext.fx.TimingFunctions', Ext.apply({
to:
Ext.define('Ext.fx.TimingFunctions', {
and change line 136 of the same file from:
}, EasingPrototype));
to:
}, EasingPrototype);
This then allows the build to go ahead.
However, when I then view the production app in the web browser, it freezes and I get the following error
Uncaught TypeError: Object # has no method 'call' process sencha-touch-all-debug.js:6767
(anonymous function) process sencha-touch-all-debug.js:6774
(anonymous function) sencha-touch-all-debug.js:6779
Ext.apply.onBeforeCreated sencha-touch-all-debug.js:5196
process sencha-touch-all-debug.js:5262
process sencha-touch-all-debug.js:5268
process sencha-touch-all-debug.js:5268
process sencha-touch-all-debug.js:5268
Ext.apply.process sencha-touch-all-debug.js:5272
Ext.Class.ExtClass sencha-touch-all-debug.js:5183
Ext.ClassManager.create sencha-touch-all-debug.js:6725
Ext.apply.define sencha-touch-all-debug.js:7407
(anonymous function) TimingFunctions.js?_dc=1379403994382:109
(anonymous function) TimingFunctions.js?_dc=1379403994382:138
There was a spelling mistake in the files fx/Abstract.js and fx/TimingFunctions.js
Actually, it's not a spelling mistake - more like a grammatical error.
Abstract.js calls a function in TimingFunctions.js. in Abstract.js it is referred to as EasingMap, where as in TimingFunctions.js it is called easingMap

Categories