I'm developing a project in React Native. I've finished the coding and after this, I have to install some dependencies such as react-native-screens, react-native-vector-icons, etc.
It appears to me: "Unable to resolve module ./InitialWindowSafeAreaInsets from node_modules\\react-native-safe-area-context\\src\\index.tsx. Below there is what appear in the Metro Bundler of my localhost:
LOGGED IN AS
INFO
16:02
Starting Metro Bundler on port 19001.
INFO
16:02
Tunnel ready.
ERROR
16:03
Unable to resolve "./InitialWindowSafeAreaInsets" from "node_modules\react-native-safe-area-context\src\index.tsx"
ERROR
16:03
Building JavaScript bundle: error
I know that I could simply install react-native-safe-area-context, but due the fact I haven't found any issue about this neither here nor in GitHub, I've preferred to be conservative and share with you the issue, instead of install the package and it becomes a snowball.
Maybe the solution is really install react-native-safe-area-context package, but I prefer to share before, because maybe anyone is being the same issue and could help with further information.
Later, I installed the react-native-safe-area-context package, and it remains the same error. How could I solve this issue?
This problem occurs with the following combinations:
expo#3.13.1
react-native-safe-area-context#0.6.0
Expo asks for react-native-safe-area-context#0.6.0, but please ignore it.
Actually, you need #0.7.3.
(Expo send 'InitialWindowSafeAreaInsets', but #0.6.0 cannot receive it. #0.6.0 can only receive 'InitialSafeAreaInsets'. Who Moved My 'Window'?)
so, please try this way.
yarn add react-native-safe-area-context#0.7.3
For some people met the issue must to change resolver in metro config file to have
'ts' extension ...
module.exports = {
resolver: {
/* resolver options */
sourceExts: ['jsx','js','tsx', 'ts'] //add here
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
Related
I don't know what is going on with my PC but every time I create the NextJS application and run development. It will return this error
error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css
TypeError: Cannot read property 'config' of undefined
(node:20136) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
wait - compiling /_error (client and server)...
error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css
TypeError: Cannot read property 'config' of undefined
at runMicrotasks (<anonymous>)
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, rename 'C:\laragon\www\bayu-personal-website\.next\cache\webpack\client-development-fallback\0.pack_' -> 'C:\laragon\www\bayu-personal-website\.next\cache\webpack\client-development-fallback\0.pack'
I can't find any cause of this error on my project because it happened after I run yarn create-next-app and yarn dev. Thank you in advance.
Create a postcss.config.js file in the root directory of my NextJS project, fixed it for me.
Example code
module.exports = {
plugins: {
},
}
I manage to create the nextJS project on Users/ directory and it turns out to fix the error. Before that, I created the project outside of Users/ directory (directly on C: and create folder on there). So maybe it was a permission thing that make the project can't run.
I dont really know why, but I installed postcss-loader, css-loader and also created a config file for postcss, postcss.config.js and then the server ran successfully!!
try out that too, I think postcss.config.js is the problem
I was facing the same problem and i fixed it by restarting the IDE AND IT JUST WORK !!
I got a very similar error while updating Tailwind from v2 to v3: TypeError: Cannot read property 'config' of undefined. This was also caused by the postcss.config.js file, as others have suggested. I needed to remove '#tailwindcss/jit': {} from the plugins section. My working config is now:
module.exports = {
plugins: {
autoprefixer: {},
},
}
Run this command in CLI : npm install postcss-flexbugs-fixes postcss-preset-env --save-exact
in postcss.config.js file , write following code:
module.exports={
"plugins" :[
"postcss-flexbugs-fixes",
[
"postcss-preset-env",
{
"autoprefixer": {
"flexbox": "no-2009"
},
"stage": 3,
"features": {
"custom-properties": false
}
}
]
]
}
and you are done ... this worked for me.
Need to create a postcss.config.js file in your root directory if it isnt there from init.
"PostCSS is a tool for transforming styles with JS plugins. These plugins can lint your CSS, support variables and mixins, transpile future CSS syntax, inline images, and more." from postcss Github
postcss.config.js:
module.exports = {
plugins: {
},
}
I'm trying to locally build the oodt_fm_plugin NPM package and link it locally to the oodt_opsui_sample_app. However, when I'm trying to do that, the following error is thrown in the browser.
Error: Minified React error #321; visit
https://reactjs.org/docs/error-decoder.html?invariant=321 for the full
message or use the non-minified dev environment for full errors and
additional helpful warnings.
The error goes away if I remove the withStyles HOC from the components in oodt_fm_plugin, but I want to preserve it for the material UI styles.
React components in the oodt_fm_plugin have been exported as follows. ( This plugin can be viewed at https://github.com/apache/oodt/tree/development/react-components/oodt_fm_plugin. )
export default withStyles(styles)(Product);
What I tried to overcome this are as follows, but none of those solved the issue.
Making react and react-dom packages in the plugin, dev dependencies
Adding the following snippet to the webpack.config.js of the plugin.
resolve: {
modules: [path.resolve('node_modules'), 'node_modules'],
},
Can someone point me in the right direction so that I can set up both oodt_fm_plugin and oodt_ui_sample_app correctly in local dev environment? Helpful advice is highly appreciated.
Well, I finally managed to solve the problem, after trying for several days. As I found out, it was not a problem with material ui, but with the Create React App. This Github issue comment helped me to solve my problem.
For extra clarity, I will quote the issue comment in this answer itself, so that it will remain here even if the comment gets deleted.
^ Ok, the solution I went for to solve this for create-react-app is to
use react-app-rewired and customize-cra.
Here is my config-overrides.js :
const {
override,
addWebpackAlias, } = require("customize-cra");
const path = require('path');
module.exports = override(
addWebpackAlias({
react: path.resolve('./node_modules/react')
}) )
Example project: https://github.com/dwjohnston/material-ui-hooks-issue/tree/master
Then, modify the start script as follows.
"start": "react-app-rewired start"
I'm encountering the following error when attempting to open a project I forked via GitHub.
success open and validate gatsby-configs - 0.492s
ERROR #11331 PLUGIN
Invalid plugin options for "gatsby-source-contentful":
- "accessToken" is required
not finished load plugins - 6.220s
I've made several edits but am unable to work on the project as I'm unable to open it at the moment. I do have a contentful account, but am fairly new to Gatsby and am unaware of how to set a new value for the accessToken.
Would I need to do this via process.env, or am I missing the process entirely?
Thank you, any help is appreciated.
Would I need to do this via process.env, or am I missing the process
entirely?
Absolutely, you need to provide to Gatsby and Contentful your access tokens. Gatsby, by default, takes the .env.development and .env.production when running gatsby develop and gatsby build respectively, so you will need to add the credentials to the environment files.
First of all, add the following snippet in your gatsby-node.js, above the module exportation:
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
This will tell Gatsby which file needs to be taken in each running command.
The next step is to fill the environment files, in both of them add:
CONTENTFUL_ACCESS_TOKEN=123456
CONTENTFUL_SPACE_ID=78910
So, finally your gatsby-config.js should look like:
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
},
},
],
}
I Am Trying To Use An npmjs module named systeminformation in the documentation it is given to use it as it is down below but it gives me an error module not found
the code from documentation:
const si = require('systeminformation');
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
My Code :
const si = require('systeminformation');
comp=()=>{
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
}
please help me with this I tried reinstalling the node module npm i systeminformation
The NpmJS Module -- https://www.npmjs.com/package/systeminformation
Install crypto:
Npm install -i crypto
This will install missing module to your local node modules
Tree remarks to your question:
As PDHide suggested to install crypto, should not really solve your problem. This is not a dependency of systeminformation, nor is it used anywhere in the code.
can you confirm, that installing systeminformation with npm I systeminformation does not show any error during the installation? This should be strange if there is an error.
be sure to use this package as a backend module within node.js. This module is not intended to be used in front end code (see documentation https://systeminformation.io/). Due to security reasons there is now way to get detailed system information from within a browser. I am pretty sure, that your error message comes while executing this code in a browser or am I wrong?
tl;dr: systeminformation package is supposed to be used as a node.js backend/server-side library and will definitely not work within a browser.
Hope that makes it clear.
Basically I am getting this list of errors after installing react-awesome-query-builder package on a brand new installed Gatsby environment.
The examples to this solution, point to add some configuration to the webpack.config.js, but on Gatsby not sure where I can add the fixes. If someone can point me to the right direction.
While there is a way to add custom webpack config settings in Gatsby, this issue might be solvable by adding Gatsby packages for less and ant design (gatsby-plugin-antd, and gatsby-plugin-less).
npm install --save antd gatsby-plugin-antd less gatsby-plugin-less
You will also need to add them into your gatsby-config.js file:
plugins: [
{
resolve: "gatsby-plugin-antd",
options: {
style: true,
},
},
{
resolve: "gatsby-plugin-less",
options: {
javascriptEnabled: true,
},
}
]
Each of them have additional configurations you can add in. For gatsby-plugin-antd, you'll want style set to true since it is using less.
For the gatsby-plugin-less package, the options will pass through to less-loader configuration. It seemed like JS being enabled was needed for react-awesome-query-builder to run, which is deprecated. I'm not sure if there is a way to avoid having that on.
I think that should get you past that specific webpack error, I'm not sure if it will make the react-awesome-query-builder demo/example work though.
If you do end up needing to edit the webpack config, you can follow the guide on gatsby's docs.