React app Module not found: Error: Can't resolve '../bugControler' - javascript

I got this problem when I started my react file
import bugModel from '../Models/bugModel'
export function retrieveBugs(){
let data = [];
data.push(new bugModel({
_id: 23456789,
name: "Crash on Load",
details:"Crashes after 3 seconds",
step:"Open application and it will crash",
version:"V2.0",
assigned:"Ryan Beasley",
creator:"Hanna Noskova",
priority:1,
time:"16:17",
}))
data.push(new bugModel({
_id: 23456789,
name: "Wont Load",
details:"Crashes after 3 seconds",
step:"Open application and it will crash",
version:"V2.0",
assigned:"Ryan Beasley",
creator:"Hanna Noskova",
priority:3,
time:"16:17",
}))
let sorted = data.sort((a,b)=>{return a.priority-b.priority})
return sorted;
}
I thought that the problem can be in './' and '../' because it is quite simillar. However I checked it and everything seems correct

We have to look at files structure to verify imports. Please provide project repository or file structure tree on diagram.
./ refers to current calalog
../ refers to one level up catalog
If you are sure about imports, please try to rerun npm start script.

Related

Error building schema with gatsby-source-filesystem config with officiel tutorial

I'm quite new to using Gatsby and for this reason I wanted to start using it by following the official tutorial. Everything went well until I came across the 4th part of it : https://www.gatsbyjs.com/docs/tutorial/part-4/#task-use-graphiql-to-build-the-query-1
When I update my gatsby-config.js file with the gatsby-source-filesystem configuration, I can't run my website locally.
When running the gatsby develop command in my terminal, I have the following error when trying to build schema :
gatsby develop
success compile gatsby files - 1.288s
success load gatsby config - 0.013s
success load plugins - 0.303s
success onPreInit - 0.004s
success initialize cache - 0.074s
success copy gatsby files - 0.049s
success Compiling Gatsby Functions - 0.080s
success onPreBootstrap - 0.087s
success createSchemaCustomization - 0.002s
success Checking for changed pages - 0.002s
success source and transform nodes - 0.089s
ERROR
Missing onError handler for invocation 'building-schema', error was 'Error: TypeError[File.publicURL]: Cannot convert to OutputType the following value: Object({ type: String, args: Object({ }), description: "Copy file to static directory and return public url to it", resolve: [function resolve] })'. Stacktrace was 'Error: TypeError[File.publicURL]: Cannot convert to OutputType the following value: Object({ type: String, args: Object({ }), description: "Copy file to static directory and return public url to it", resolve: [function resolve] })
at TypeMapper.convertOutputFieldConfig (/Users/nicolas/my-gatsby-site/node_m odules/graphql-compose/src/TypeMapper.ts:419:13)
at ObjectTypeComposer.setField (/Users/nicolas/my-gatsby-site/node_modules/g raphql-compose/src/ObjectTypeComposer.ts:445:40)
at /Users/nicolas/my-gatsby-site/node_modules/graphql-compose/src/ObjectType Composer.ts:479:14
at Array.forEach (<anonymous>)
at ObjectTypeComposer.addNestedFields (/Users/nicolas/my-gatsby-site/node_mo dules/graphql-compose/src/ObjectTypeComposer.ts:468:28)
at forEach (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:764:39)
at Array.forEach (<anonymous>)
at /Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:764:18
at async Promise.all (index 54)
at updateSchemaComposer (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:168:3)
at buildSchema (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:71:3)
at build (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/index.js:112:18)
at buildSchema (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/servic es/build-schema.ts:19:3)'
⠸ building schema
Then the building schema command is running forever and my site can't launch.
I know the issue is when adding gatsby-source-filesystem into the gatsby-config.js file because when I delete it, I can run gatsby develop without any issue.
Here is my gatsby-config.js file, nearly identical to the one in the tutorial (I just changed the blog title) :
module.exports = {
siteMetadata: {
title: `Arckablog`,
siteUrl: `https://www.yourdomain.tld`,
},
plugins: [
"gatsby-plugin-image",
"gatsby-plugin-sharp",
{
resolve: "gatsby-source-filesystem",
options: {
name: `blog`,
path: `${__dirname}/blog`,
}
},
],
}
I have seen a similar question on stackoverflow here : Error building schema with gatsby-source-filesystem config (following official tutorial) and I tried updating both my Gatsby version and the gatsby-source-filesystem version but none of it worked out for me.
Can you maybe advise me please ?
Thank you for your help !
Nicolas
I encountered same problem.
I was running
npm install gatsby-source-filesystem
from different folder. Then I changed my current folder to project directory and ran npm install gatsby-source-filesystem everything worked fine

React Native Error Cannot find module 'metro-config/src/defaults/blacklist'

I'm currently working on a project in React Native, yesterday it was working perfectly with no errors, and now all of a sudden I'm getting this error.
error Cannot find module 'metro-config/src/defaults/blacklist'
Require stack:
- /Users/sri/Downloads/cc_x/reactnativelcsapp/VitalitiApp/metro.config.js
I've tried soo many solutions, removing the node modules and installing it back, updating the modules, looking to change the backlist. I've checked my files and I can't find the blacklist file but I'm trying to fix it but honestly have no idea how to fix it. I was wondering if anyone would know what to do.
the blacklist file seems to be renamed as exclusionList
const blacklist = require('metro-config/src/defaults/exclusionList');
use this line instead in metro.config.js
In newer versions of metro-config the function is now called exclusionList. So change the blacklist reference with exclusionList in metro-config.js file which is located in the project root directory.
const exclusionList = require('metro-config/src/defaults/exclusionList');
If still issue persists, then add metro-config as a dev dependency:
npm install -D metro-config
I had the same Issue as others. Changing it to
const exclusionList = require('metro-config/src/defaults/exclusionList');
Fixed my issue.
I had to create metro.config.js and insert the following code since I was using AWS Amplify:
const blacklist = require('metro-config/src/defaults/exclusionList');
module.exports = {
resolver: {
blacklistRE: blacklist([/amplify\/#current-cloud-backend\/.*/]),
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
I had the same error in myapp/node_modules/expo-yarn-workspaces/index.js
From my require stack so I opened this file and found const blacklist = require('metro-config/src/defaults/blacklist'); into my app node modules.
So I changed it to
const blacklist = require('metro-config/src/defaults/exclusionList');
which fixed my problem

standard aurelia template referencing file outside src directory

I have created a new aurelia project via au new and have no issues referencing typescript files in the src folder. For example in main.ts this works:
main.ts
import { Util } from './util'; //in aurelia-app\src
new Util();
util.ts
export class Util{ }
When I move util.ts up one level, this breaks the au CLI:
import { Util } from '../util'; //in aurelia-app\
Error:
Tracing main... ------- File not found or not accessible ------
| Location: D:/temp/aurelia-test1/aurelia-app/util.js
| Requested by:> D:/temp/aurelia-test1/aurelia-app/src/main.js
| Is this a package?
Make sure that it is configured in aurelia.json and that it is not a
Node.js package
Can someone tell me why the CLI doesn't like this and possibly how to fix it ?
There is a clue insofar as the log states its looking for util.js however this doesnt explain why it does work when util.ts is in the src folder because i do not see util.js in this folder either.
update
As per #Jesse answer below you can modify aurelia.json to fix the problem as stated above - however this fails if you want to go another directory higher. For example
import { Util } from '../../util';
That is because your aurelia.json is configured to transpile all .ts files in the src-folder:
"transpiler": {
"id": "typescript",
"displayName": "TypeScript",
"fileExtension": ".ts",
"dtsSource": [
"./custom_typings/**/*.d.ts"
],
"source": "src/**/*.ts" <--- right here
},
Therefore it won't transpile your typescript file in the root. You can change the transpiler settings in the aurelia.json to overcome this, but I'd recommend keeping your typescript in the src-folder.

I am finding trouble using log4js-protractor-appender

My log4js.js file code
'use strict';
var log4js = require('log4js');
var log4jsGen = {
getLogger: function getLogger() {
log4js.loadAppender('file');
log4js.addAppender(log4js.appenders.file('./ApplicationLogs.log'), 'logs');
var logger = log4js.getLogger('logs');
return logger;
}
};
module.exports = log4jsGen;
My conf.js file(specific to appender section only)
"appenders": [{
"type": "log4js-protractor-appender",
"append": 'false',
"maxLogSize": 20480,
"backups": 3,
"category": "relative-logger"
}],
Problem:
1) IS there a way that the logs will get overwritten in each run.
2) Why log4js-protractor-appender is not working, instead log4js is working, the merit of the previous is that it resolves the promises which is passed as an argument.
Thats a great question. Yes log4js-protractor-appender is awesome. It is built specially for Protractor based environments and it places all logger command in Protractor Control flow and resolves Protractor promises before logging.
You were using it incorrectly. The appender options are not part of Protractor config options but can be integrated. The approach you have is a little old one and I have updated by blog post
These are the steps as an answer to your question-2
Step 1: Install log4js npm module
Step 2: Install log4js-protractor-appender module
Step 3: Add the logger object creation logic in protractor beforeLaunch() and assign it onto ​​browser protractor global object
'use strict';
var log4js = require('log4js');
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: [
{ type: 'log4js-protractor-appender', category: 'protractorLog4js' },
{
type: "file",
filename: './logs/ExecutionLog.log',
category: 'protractorLog4js'
}
]
});
},
onPrepare: function() {
browser.logger = log4js.getLogger('protractorLog4js');
},
Step 4: Use logger object in your tests by accessing through browser.logger
describe('sample test', function(){
it('Sample Check', function(){
browser.get("http://www.protractortest.org/#/");
browser.logger.info("Testing Log4js");
browser.sleep(5000);
browser.logger.info('Displayed text is:', browser.getCurrentUrl());
var elm = element(by.css('.lead'))
browser.logger.info('Displayed text is:', elm.getText());
});
});
But one thing to note is - This appender is just an console appender and will not be able to write to file. The file will still contain unresolved promises
Sample Output:
[21:54:23] I/local - Starting selenium standalone server...
[21:54:23] I/launcher - Running 1 instances of WebDriver
[21:54:25] I/local - Selenium standalone server started at http://192.168.1.5:60454/wd/hub
Started
[2017-02-03 21:54:30.905] [INFO] protractorLog4js - Testing Log4js
[2017-02-03 21:54:35.991] [INFO] protractorLog4js - Displayed text is: http://www.protractortest.org/#/
[2017-02-03 21:54:36.143] [INFO] protractorLog4js - Displayed text is: Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.
.
Answer to your Question 1: How to overwrite logs each run. I added a simple logic in beforeLaunch() to delete old logs if they exist and its part of the code snippet I pasted above
I have check this issue with and followed the steps mentioned in Answer 1 and it works for me.
Earlier I was getting log output in Console only but now I am getting log in console and file also.
I corrected the file path passing and Set type: "file" in log4js configure in conf file.
Log4js in Conf file
Log appender in file
Please let me know if you face any issue again.
Thanks

Meteor packages & variable scope

My Meteor project is structured in packages only (there are several articles on the internet recommending and explaining on how to do this). I ran into a basic problem which I can not seem to solve. Here is the issue stripped down to a minimum test case:
I have two packages, 'one' and 'two' (created with 'meteor create --package' and added to the project subsequently) Package two holds a variable and exports this variable. Package one logs the contents of this variable to the console:
two.js:
two_var = 'two'
package.js (two):
Package.describe({
name: 'two'
});
Package.onUse(function (api) {
api.addFiles('two.js', 'client');
api.export('two_var', 'client')
});
one.js:
Meteor.startup(function() {
console.log(two_var) //two_var found, unexpected
})
setTimeout(function () {
console.log(two_var) //two_var found, unexpected
}, 3000)
console.log(two_var) //two_var not found, expected
package.js (one):
Package.describe({
name: 'one'
});
Package.onUse(function(api) {
//api.use('two', 'client'); //not using two, but two_var found in certain situations
api.addFiles('one.js', 'client');
});
As you can see the variable from package two can be accessed in situations I would not expect so. Am I overlooking something or do I misunderstand the concept of the package?

Categories

Resources