Getting this error when running ts-jest.
Error: Member.relationMappings.primaryAssignment: modelClass: could not resolve ./MemberAssignment using modelPaths
primaryAssignment: {
relation: Model.HasOneRelation,
modelClass: path.join(__dirname, 'MemberAssignment'),
join: {
from: 'members.primary_member_assignment_id',
to: 'member_assignments.id',
},
},
Works perfectly fine when using tsc
Related
When running the below code in NodeJS
const yargs=require("yargs");
yargs.command({
command:"add",
describe:"add something",
builder:{
title:{
describe:"the title property",
demandOption:true,
type:"string"
},
body:{
describe:"damn",
demandOption:true,
type:"string"
}
},
handler:function(argv){
console.log(argv.title)
}
})
I get the below error
https://drive.google.com/file/d/13lmzJ23IRdNkAfbG1A2bhzRZvPQzhaqn/view
I have done everything the right way but still, it displays the error
"module not found".
How can I resolve the issue?
TypeError: Cannot read properties of null (reading 'jsonType')
at validateNonObjectFieldsProp (/static/js/app.bundle.js:169457:16)
at _default (/static/js/app.bundle.js:169425:155)
at visitors.reduce._objectSpread._problems (/static/js/app.bundle.js:167933:17)
at Array.reduce ()
at /static/js/app.bundle.js:167932:21
at /static/js/app.bundle.js:167951:70
at /static/js/app.bundle.js:168067:12
at /static/js/app.bundle.js:168082:95
at Array.forEach ()
at traverseSchema (/static/js/app.bundle.js:168081:9)
Showing the given error while performing the sanity start command, but it not showing on command line. While visiting the localhost website there's the error is showing this. I have tried downgrading the versions for sanity but still not solved this issue.
You missed type document in schema
Eg:
export default {
name: "user",
title: "User",
type: "document",
fields: [
{
name: "userName",
title: "UserName",
type: "string",
},
{
name: "image",
title: "Image",
type: "string",
},
],
};
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)/
}
]
}
}
Can you guys suggest me how to add local js files in application
I have tried by adding the local JS file path in index.html like below
<script src="thirdpartyscripts/amcharts.js"></script>
Here **thirdpartyscripts** is my directory.
but getting the error like below.
Error
Copy this folder and file in your target/www folder. Or alternatively use webpack to do this for you in webpack.commons.js. Look at the last line I have added
new CopyWebpackPlugin([
{ from: './node_modules/core-js/client/shim.min.js', to: 'core-js-shim.min.js' },
{ from: './node_modules/swagger-ui/dist', to: 'swagger-ui/dist' },
{ from: './src/main/webapp/swagger-ui/', to: 'swagger-ui' },
{ from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
{ from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
// { from: './src/main/webapp/sw.js', to: 'sw.js' },
{ from: './src/main/webapp/robots.txt', to: 'robots.txt' },
{ from: './src/main/webapp/thirdparty/sth.js', to: 'thirdparty/sth.js' }
]),
I have two models: Users and InstalledApps. Models are like this:
//Users Model
attributes:{
name: 'string',
age: 'string',
installedApps:{
collection: 'installedApps',
via: 'users'
}
}
My InstalledApps model is like this:
attributes:{
deviceID : 'string',
users:{
collection:'users',
via:'installedApps'
}
}
Now I have already created the user with id 1 and 2.
But when I insert data in InstalledApps via postman like this:
{
"users": [1,2],
"deviceID": "123456",
}
It pops an error: Unknown rule: default. I don't know where I am wrong?
Your models are fine. Have you made sure you're posting the data as JSON? In the Body tab in Postman, select raw and then change from Text to JSON (application/json). Remove the surplus comma after "123456" and your request should go through without problems. Also, make sure you're doing a POST request to the /installedApps route, e.g. http://localhost:1337/installedApps.
I tested this with the model definitions you posted in a fresh Sails.js app, getting installedApps entries inserted correctly with associations to users entries.
I think you made your models wrong.
You should use http://sailsjs.com/documentation/concepts/models-and-orm/associations/through-associations .
Then you should have 3 models. USER, APP, INSTALLED_APPS.
Your user model will get:
//Users Model
attributes:{
name: 'string',
age: 'string',
installedApps:{
collection: 'APP',
via: 'user',
through: 'installedApps'
}
}
and your APP model:
//APP Model
attributes:{
device: 'string',
installedApps:{
collection: 'APP',
via: 'app',
through: 'installedApps'
}
}
and finally your INSTALLED_APPS:
//INSTALLED_APPS Model
attributes:{
user: {
model: 'user'
},
app: {
model: 'app'
}
}
Then you will just use simple create of INSTALLED APP for every user/app or blueprint http://sailsjs.com/documentation/reference/blueprint-api/add-to
Hope it helps.