I was trying Sails.js beta version (1.0.0-46) and noticed that flash messages are not available out-of-box:
req.flash(type, message)
I got a TypeError: req.flash is not a function message when trying to use it.
Ouch... just found the answer right in the upgrade docs (Upgrading to v1.0).
The connect-flash middleware has been removed (so req.flash() will no longer be available by default). If you wish to continue using req.flash(), run npm install --save connect-flash in your app folder and add the middleware manually.
Run the command bellow:
npm install --save connect-flash
And modify the config/http.js file:
middleware: {
flash : require('connect-flash')(),
order: [
'cookieParser',
'session',
'flash', // <-- add this
// 'bodyParser',
'compress',
'poweredBy',
'router',
'www',
'favicon',
],
Its in its session object req.session.flash, you can use it as
req.session.flash{type:'success', message:'your message'}
Related
Following Scully install directions:
ng add #scullyio/init
for a basic Angular 14 application and getting:
TypeError: entry.message.split is not a function
at MapSubscriber.project (...\node_modules\#angular-devkit\core\src\logger\indent.js:35:58)
at MapSubscriber._next (...\node_modules\#angular-devkit\core\node_modules\rxjs\internal\operators\map.js:49:35)
at MapSubscriber.Subscriber.next (...\node_modules\#angular-devkit\core\node_modules\rxjs\internal\Subscriber.js:66:18)
at Subject.next (...\node_modules\#angular-devkit\core\node_modules\rxjs\internal\Subject.js:60:25)
at IndentLogger.log (...\node_modules\#angular-devkit\core\src\logger\logger.js:83:23)
at IndentLogger.error (...\node_modules\#angular-devkit\core\src\logger\logger.js:98:21)
at ...\node_modules\#scullyio\init\src\ng-add\index.js:89:24
at MergeMapSubscriber.project (...\node_modules\#angular-devkit\schematics\src\rules\call.js:75:24)
at MergeMapSubscriber._tryNext (...\node_modules\#angular-devkit\schematics\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
at MergeMapSubscriber._next (...\node_modules\#angular-devkit\schematics\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
node # 16.17.0
npm # 8.19.1
And Angular project has all dependencies up to date as of posting.
Not sure what I can be doing wrong with a single ng command, but can anyone help me resolve this error? There's a GitHub issue from June with this exact error that just states to update Angular and npm. This was my first attempt to use Scully, and I'm not filled with confidence.
I am looking for some best practices for publishing and developing nuxt plugins. I would like to write a plugin which gives our web applications the possibility to request oauth tokens from everywhere. I have written this plugin localy in my project and it works. Now my target is to move the code to a seperate plugin project and upload it to npm so every one in my company might use it easily. Are there any guides how to setup a nuxt plugin project? I found several guides for creating vue-plugins but the structure of them are a bit different to nuxt. I do not have a install method. Because my plugin simply wraps vuex store methods defined in oAuthStore.js as global methods, which can be used when I register my plugin in nuxt.config.js.
Vue plugins seems to work a bit different.
I upload a vue-plugin with an install method. When I try to import it and run my application on dev server (npm run dev) i always get the error message:
This dependency was not found: * my-plugin in ./plugins/vuex-persisted.js friendly-errors 16:55:24
friendly-errors 16:55:24
To install it, you can run: npm install --save my-plugin
My plugin has been uploaded to npm correctly and I have used it by executing npm install --save my-plugin so it has an entry on dependency list in package.json.
When I try to npm-link my-plugin I get the same error. This is the only way I know for rapid prototyping because I do not want a npm publish every time I want to test something. Does everyone know a way for a better developing workflow for working on nuxt plugins?
Thanks for any help.
Best regards
Moritz
/** oAuthPlugin.js **/
import oAuthStore from './oAuthStore.js'
import Cookies from 'js-cookie'
import createPersistedState from 'vuex-persistedstate'
export default ({store, isHMR, app}, inject) => {
app.store.registerModule('oAuth', oAuthStore );
var me = app;
inject('getOAuthCredentials', () => {
var data = {};
if(app.$store) {
var data = app.$store.getters["oAuth/getAuthCredentials"];
}
return data;
});
inject('requestOAuthCredentials', (data) => {
if(me.store) {
me.store.commit("oAuth/requestOAuthCredentials", data);
}
});
if (isHMR) return
// add persisted state as a vue mounted mixin
if (!app.mixins) {
app.mixins = []
}
app.mixins.push({mounted () {
createPersistedState({
key: 'vuex-persisted',
paths: ['oAuth'],
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) => Cookies.set(key, value, {expires: 3}),
removeItem: key => Cookies.remove(key)
}
})(store);
}});
}
/** nuxt.config.js **/
/*
** Plugins to load before mounting the App
*/
plugins: [
{ src: '~/plugins/vuex-persisted', ssr: false },
{ src: '~/plugins/oAuthPlugin.js' }
],
When I clean webdriver-manager and update, it is unable to download chrome driver and update-config.json. Later on when I start protractor it is complaining couldn't find update-config.json.
package.json
"scripts": {
"webdrivermanager:update": "node node_modules/protractor/bin/webdriver-manager update --versions.standalone=3.4.0 --ignore_ssl",
"webdrivermanager:clean": "node node_modules/protractor/bin/webdriver-manager clean",
"install": "npm run webdrivermanager:clean && npm run webdrivermanager:update"
}
protractor.conf.js
seleniumServerJar: '../../node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar',
multiCapabilities: [
{browserName: 'chrome'}
//specify if any other browser
],
directConnect: true,
Now when I do npm install, I can not see chrome driver and
update-config.json at
node_modules\protractor\node_modules\webdriver-manager\selenium
location
webdriver-manager update log
> node node_modules/protractor/bin/webdriver-manager update --versions.standalon
e=3.4.0 --ignore_ssl
[09:58:34] I/http_utils - ignoring SSL certificate
(node:10944) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): TypeError: Cannot read property 'ListBucketResult' of undefined
[09:58:34] I/downloader - curl -o C:\..\..\node_mo
dules\protractor\node_modules\webdriver-manager\selenium/selenium-server-standal
one-3.4.0.jar https://selenium-release.storage.googleapis.com/3.4/selenium-serve
r-standalone-3.4.0.jar
[09:58:35] I/downloader - curl -o C:\..\..\node_mo
dules\protractor\node_modules\webdriver-manager\selenium/geckodriver-v0.16.1.zip
https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0
.16.1-win64.zip
[09:58:36] I/update - geckodriver: unzipping geckodriver-v0.16.1.zip
In my log also chrome driver is not downloading anymore. For this reason I can not start my protractor as update-config.json is not available. Any idea would be great. Thanks
During a previous update call, the xml response was cancelled before the file could be created. There are two options (features to fix this are not complete yet):
delete the chrome-response.xml and then call update again
wait an hour and make an update request again. The last modified time will invalidate that file and it will make a request and will replace the chrome-response.xml.
On my end, if my webdriver-manager instance was closed.
I am required to delete npm and npm-cache folders from roaming and reinstall protractor again.
Right after installing protractor, webdriver-manager update needs to be executed immediately.
If an error appears, make sure to run node.js cmd as an admin.
With these steps, I was able to download drivers properly.
That was very weird. I did everything nothing helped. Actual reason was my organization blocked the chrome driver api site. chrome-response.xml is the main clue that is showing access denied message so, I came to know actual reason.
I requested to #cnishina to thrown an actual error message if chrome driver website is not reached.
For some reason I should use Node.js 6.x (actually 6.10.0) and I'm trying to run koa2 with Babel as described here. My code looks like this
const Koa = require('koa');
var app = new Koa();
// --- middlewares ---
async function a(){await 1} // okay here!
console.log(a());
const serve = require('koa-static');
app.use(serve('./web'));
app.use(require('koa-cookie').default());
app.use(require('koa-bodyparser')()); // fails here
And I'm getting error
D:\Project\node_modules\koa-bodyparser\index.js:72
return async function bodyParser(ctx, next) {
^^^^^^^^
SyntaxError: Unexpected token function
Running node with nodemon index.js --exec babel-node on Windows
Works perfect on Node 7.x, but I need to use 6 unfortunately :(
async and await are not yet supported in Node.js 6.x. They are ES2017 features and are only supported in Node 7.6+.
The Babel preset you're using is obviously not working - make sure you are using the correct babel preset (ES2017) as per the instructions on the Babel site.
I've tried to figure out how to install a mongodb 3.4 instance using this chef cookbook. Nevertheless, I've not able to get to install it.
This is my mongodb.rb file content:
node.default['mongodb']['package_version'] = '3.4'
include_recipe 'mongodb::default'
And my metadata.db: depends 'mongodb', '~> 0.16.2'.
I've tried to verify it on centos-72 platform using kitchen verify centos-72. I'm getting this message:
ERROR: yum_package[mongodb-org] (mongodb::install line 77) had an error: Chef::Exceptions::Package: Version ["3.4"] of ["mongodb-org"] not found. Did you specify both version and release? (version-release, e.g. 1.84-10.fc6)
I'm realizing this cookbook tries to add this yum_repository:
yum_repository 'mongodb' do
description 'mongodb RPM Repository'
baseurl "http://downloads-distro.mongodb.org/repo/redhat/os/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}"
action :create
gpgcheck false
enabled true
end
And according to this mongo documentation the link repository should have to be:
https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
instead of
"http://downloads-distro.mongodb.org/repo/redhat/os/..."
The repo you are using does not have version 3.4 available. You can verify this manually by just looking at the RPMs in http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/