Invalid webpack configuration object - node.js

I wanted to access modules like this
var Builder = require('Builder');
instead of
var Builder = require('./app/components/Builder');
So I generated a
webpack.config.js
file using
webpack version 1.12.13
Here is my file
module.exports =
{
entry :'./app/app.jsx',
output :{
path : __dirname,
filename: './client/bundle.js'
},
resolve :{
root : __dirname,
alias : {
},
extensions : ['.js','.jsx']
},
module :{
loaders : [
{
loader :'babel-loader',
query :{
presets:['react','es2015']
},
test :/\.jsx?$/,
exclude :/(node_modules|bower_components)/
}
]
}
}
All was fine until i updated my
webpack to version 3.5.4
and run webpack i get this error in the resolve object
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolve has an unknown property 'root'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
What is the problem and Which change do i have to make ?

resolve.root is not a valid webpack configuration property. https://webpack.js.org/configuration/resolve/
All you have to do is remove root from the resolve object
module.exports =
{
entry :'./app/app.jsx',
output :{
path : __dirname,
filename: './client/bundle.js'
},
resolve :{
alias : {
},
extensions : ['.js','.jsx']
},
module :{
loaders : [
{
loader :'babel-loader',
query :{
presets:['react','es2015']
},
test :/\.jsx?$/,
exclude :/(node_modules|bower_components)/
}
]
}
}

Related

(this.internalValue || []).findIndex is not a function when enabling multiple selection on v-select

I am using Vue.js with Vuetify.
Following is my minimal reproducible example:
<template>
<v-app>
<v-select v-model="site" :items="sites" item-value="_id" item-text="name"></v-select>
<v-btn #click="showSelections">Show Selections</v-btn>
</v-app>
</template>
<script>
export default {
name: 'App',
data: () => ({
site: [],
sites: [
{
name: 'Vancouver',
_id: '5d9c276784e00100699281e2',
},
{
name: 'LA',
_id: '5d9c276784e00100699281e5',
},
{
name: 'Montreal',
_id: '5d9c276784e00100699281e3',
},
],
}),
methods: {
showSelections: function() {
console.log(this.site);
}
}
};
</script>
This example works perfect until you want to enable multiple selection on the v-select component.
<v-select v-model="site" :items="sites" multiple item-value="_id" item-text="name"></v-select>
As soon as you click the combobox, you'd get this:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in v-on handler: "TypeError: (this.internalValue || []).findIndex is not a function"
found in
---> <VSelectList>
<VThemeProvider>
<VMenu>
<VSelect>
<VMain>
<VApp>
<App> at src/App.vue
<Root>
TypeError: (this.internalValue || []).findIndex is not a function
at VueComponent.findExistingIndex (VSelect.ts?1576:338)
at VueComponent.selectItem (VSelect.ts?1576:816)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.Vue.$emit (vue.runtime.esm.js?2b0e:3888)
at click (VSelectList.ts?7bd1:169)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
This seems to be an issue caused by Vue CLI 4.5.11 transpiling Vuetify. If you remove vuetify from transpileDependencies, your example works properly:
// vue.config.js
module.exports = {
// transpileDependencies: [
// 'vuetify'
// ]
}
Interestingly, this isn't a problem at all (no config changes needed) with Vue CLI 5.0.0-alpha.4, so consider upgrading.
I had the same problem. I leave you here as I have it in case it works for you:
<!-- VueJS Template -->
<v-select :items="arrayItems" v-model="arrayItemsSelected" label="Items" item-text="text" outlined multiple chips attach dark></v-select>
// VueJS Data
export default {
data: () => ({
arrayItemsSelected: [],
arrayItems: [
{ value: "Item1", text: "Item1" },
{ value: "Item2", text: "Item2" },
{ value: "Item3", text: "Item3" },
{ value: "Item4", text: "Item4" },
{ value: "Item5", text: "Item5" },
],
}),
}
I had the same issue when I was toggling the multiple property of the v-select. See the reproduction link: https://codepen.io/kkojot/pen/MWOpYqZ
To avoid this error you have to clear the property bound to v-model and change it empty object {} or empty array [] accordingly.
computed: {
isMultiple() {
//comment the if statment below to see the 'TypeError: (this.internalValue || []).findIndex is not a function'
if (this.multiple) this.site = [];
else this.site = {};
return this.multiple;
},
},

Nodejs: Invalid or unexpected token while using decorators typescript

I'm was using type-graphql to create a simple API. So I created a simple query which is working fine before.
#Resolver()
class B {
#Query({nullable: true})
async a(#Arg("b", () => String) b: string) {
}
}
But when I integrated babel in my project it's start throwing this error:
/Users/robot/Desktop/node-test/src/index.ts:37
var _a = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(#(0, _typeGraphql.Arg)("b", function () {
^
SyntaxError: Invalid or unexpected token
.babelrc:
{
"presets": [
"#babel/preset-env",
"#babel/preset-typescript"],
"plugins": [
["#babel/plugin-proposal-decorators", {"legacy": true}],
"#babel/plugin-proposal-class-properties",
"#babel/plugin-transform-typescript",
"#babel/plugin-transform-runtime"
]
}
Try removing {"legacy": true} from your .babelrc unless you are sure that you need it. If you do need it, using {"legacy": true} with #babel/plugin-proposal-decorators needs some additional configuration according to https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy :
When using the legacy: true mode, the setPublicClassFields assumption must be enabled to support the #babel/plugin-proposal-decorators.
The example configuration they give is
{
"assumptions": {
"setPublicClassFields": true
},
"plugins": [
["#babel/plugin-proposal-decorators", { "legacy": true }],
["#babel/plugin-proposal-class-properties"]
]
}
Applying that to example to your .babelrc would change it to the following. Does that solve your issue?
{
"assumptions": {
"setPublicClassFields": true
},
"presets": [
"#babel/preset-env",
"#babel/preset-typescript"],
"plugins": [
["#babel/plugin-proposal-decorators", {"legacy": true}],
"#babel/plugin-proposal-class-properties",
"#babel/plugin-transform-typescript",
"#babel/plugin-transform-runtime"
]
}

How can I run grunt svgstore?

When I run "grunt svgstore" I get this:
No "svgstore" targets found. Warning: Task "svgstore" failed. Use --force to continue. Aborted due to warnings.
Why?
This is part of my gruntfile (I can't post more).
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-svgstore');
grunt.initConfig({
svgstore: {
options: {
formatting : {
indent_size : 2
}
},
default: {
files: {
'images/svg/defs.svg': ['images/svg/*.svg'],
},
},
},
},
});
// Default task(s)
grunt.registerTask('default', ['sass_globbing', /*'sprite:icons_dev'*/, 'sass']);
grunt.registerTask('icon_sprite', ['sprite:icons_dev']);
//grunt.registerTask('stage_deploy', ['sass_globbing', 'sprite:flags_dev', 'sprite:icons_dev', 'sass']);
//grunt.registerTask('prod_deploy', ['sass_globbing', 'sprite:flags_prod', 'sprite:icons_prod', 'tinypng', 'sass']);
};
I had a similar problem. Not sure what is the solution but I have solved it after I took a look on sample Gruntfile.js. The only difference I can spot between mine and yours Gruntfile is that I call loadNpmTasks after initConfig.
Take a look here:
module.exports = function(grunt) {
grunt.initConfig({
svgstore: {
options: {
prefix : 'pfx-', // This will prefix each ID
svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
viewBox : '0 0 100 100',
xmlns: 'http://www.w3.org/2000/svg'
},
formatting : {
indent_size : 2
},
symbol : {},
includedemo: true,
cleanup: true,
cleanupdefs: true,
},
default : {
files: {
'export/pfx-icons.svg': ['svgs/*.svg'],
},
},
},
});
grunt.loadNpmTasks('grunt-svgstore');
grunt.registerTask('default', ['svgstore']);
};

Update existing items in nested array using mongoose

There is a schema as mentioned below. I'm trying to update the existing todo.task.
The problem is, I am storing the path as var done = 'todos.'+todoIndex+'.tasks.'+taskIndex+'.done' and it does not work. I was looking to update like todos.0.tasks.0.done:req.body.done, but it doen't work at all.
(todoIndex and taskIndex are in string which stores the index values)
What is the correct way of doing this?
var mongoose = require('mongoose');
var todoSchema = {
authorId : mongoose.Schema.Types.ObjectId,
date:{
type:Date
},
title : {
type : String
},
description : {
type : String
},
todos : [ {
created : {
type : Date
},
updated : {
type : Date
},
title : {
type : String
},
description : {
type : String
},
done:{
type:Boolean
},
deadline:{
type:Date
},
tasks : [ {
done : Boolean,
task : String
} ]
} ]
}
module.exports = new mongoose.Schema(todoSchema);
module.exports.todoSchema = todoSchema;
I was trying to build the Api like this:
api.put('/notebooks/todo/update/:pid',wagner.invoke(function(Todo,User){
return function(req,res){
var taskIndex=req.body.taskIndex;
var todoIndex=req.body.todoIndex;
var done = 'todos.'+todoIndex+'.tasks.'+taskIndex+'.done';
console.log(done);
Todo.update({_id:req.params.pid},{$set:{
done : req.body.done,
}}, function(err,done){
console.log( done);
})
}}));
If you're using a recent Node version, you can use a computed property name:
Todo.update({ _id : req.params.pid }, { $set : { [ done ] : req.body.done } }, ...
Otherwise, you need to use an intermediate object:
var done = 'todos.'+todoIndex+'.tasks.'+taskIndex+'.done';
var obj = {};
obj[done] = req.body.done;
Todo.update({ _id : req.params.pid }, { $set : obj }, ...

param-set type for LoadBalancerPorts

I'm trying to use awssum.io to delete load balancer listeners (http://awssum.io/amazon/elb/delete-load-balancer-listeners.html) but I could not figure out what param-set type looks like. I have tried [1000, 2000] but it did not work. Here is partial code:
var params = { LoadBalancerName: 'my_balancer_name',
LoadBalancerPorts: [2000, 3000] };
var config = {};
config.accessKeyId = 'abc';
config.awsAccountId = '123';
config.secretAccessKey = 'def';
config.region = 'us-1';
var elb = new Elb(config);
elb.DeleteLoadBalancerListeners(params, function(err, data)
{
....
});
Thanks for your helps!
I found out that this is lib bug. Here is the fix, the file node_modules/awssum/lib/elb-config.js, change from type: 'param-set' to type: 'param-array',
DeleteLoadBalancerListeners : {
url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancerListeners.html',
defaults : {
Action : 'DeleteLoadBalancerListeners'
},
args : {
Action : {
required : true,
type : 'param',
},
LoadBalancerName : {
required : true,
type : 'param',
},
LoadBalancerPorts : {
required : true,
// type : 'param-set',
type : 'param-array',
prefix : 'member',
},
},
},

Resources