Cannot find module 'D:\Resources\DevOps\eslint\bin\eslint.js' - reactjs

I'm trying to integrate eslint with react
I'm getting this error when I run lint command
enter image description here

because you installed eslint locally (inside your current project), you have to call it from .node_modules folder of your project like this
./node_modules/.bin/eslint src/**/*.js src/**/*.jsx

Related

getting error when run npm start command with gatsby

When I run command npm start it's giving me error
ERROR
gatsby develop
Start development server. Watches files, rebuilds, and hot reloads if
something changes
And when I run command gatsby build it's giving me this error:
gatsby can only be run for a gatsby site. Either the current
working directory does not contain a valid package.json or 'gatsby' is
not specified as a dependency
I tried to delete node_modules and install again but still giving me the same error. How can I fix this?
It seems that you are not running the commands in the proper folder.
npm start, gatsby develop or gatsby build must be triggered in the root of your Gatsby project, where the package.json is located.
Share more details about where and how are you trying to run npm start and even your project structure in order to know what's going on.

Set jest node_module folder path in CRA project

I have a CRA project, the whole app and its package.json file are located inside the /app folder, so does the node_module folder.
I use vs code and I installed the jest extension, when I try to run a single test by click right button and then run test, I get the following jest error:
Error: Cannot find module '/Users/my_user_name/myApp/node_modules/.bin/jest'
As you can see it looks for jest in the wrong folder, it should be instead:
Error: Cannot find module '/Users/my_user_name/myApp/app/node_modules/.bin/jest'
Any suggestion where I can change this setting?
I know there's a VS Code setting called jest.pathToJest but it doesn't work for my case.

Trying to compile React Native app and I am getting an error about React.js not existing

I am trying to compile my first React Native project, and it all works fine from the CLI, until I try to install a new library.
After installing any library, I get various errors, culminating in this:
error: bundling failed: Error: While trying to resolve module `react` from file `/Users/myname/Desktop/Projects/ProjectName/App.js`, the package `/Users/myname/Desktop/Projects/ProjectName/node_modules/react/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/myname/Desktop/Projects/ProjectName/node_modules/react/index.js`. Indeed, none of these files exist:
I have, indeed, confirmed that those files exist.
What is going on here? I'm constantly having these errors as I am trying to use React Native, even when rebuilding the app multiple times and trying over.
Do the following steps:
Stop metro bundler
Delete node_modules folder
cd into your project folder and run:
'npm install'

'npm run build' (ejected project has SCSS loader) error

My React project (made with create-react-app) was ejected before I started the project. I included an SCSS loader in the webpack file.
Now, when I try to run 'npm run build', the following error gets shown:
Invalid CSS after "i": expected 1 selector or at-rule, was "import React from '"
I don't know where exactly I had gone wrong, but it might have been something with css-loader.
I created a fresh project (didn't eject the project this time), installed node-sass-chokidar [guide for using sass/scss in your React project], copied my src folder into the new project, installed all the other dependencies, and finally changed the import statements from '.scss' to '.css'.
This worked.

jsx-control-statements - ReferenceError: Choose is not defined

I am using the jsx-control-statements node module for React with webpack.
Normally this works great, but when I copied my project to another folder and ran npm install using the same package.json as before, jsx-control-statements doesnt seem to be getting recognized by webpack.
jsx-control-statements is meant to desugar the tags in the render() and turn it into code react recognizes. Its not doing that in this case.
I see the final code running in the inspector that 'Choose' was never transpiled into valid code.
_react2.default.createElement(Choose, null,
The error I am getting is:
Uncaught ReferenceError: Choose is not defined
webpack.config.js and package.json and my source code for the app are unchanged. from a working app and this new one in another folder.
I have tried:
installing jsx-control-statements manually locally and globally.
copying and pasting the entire node_modules folder from the good project into this new project.
Run eslint with eslint-jsx-control-statements plugin, no errors
Still the problem persists. I believe their is a problem in the building of project, but I am out of ideas what to try next.
The issue was simple as I felt it would be. I was missing a tiny .babelrc file which included a plugin reference to jsx-control-statements
{
// my babel config here
"plugins": ["jsx-control-statements"]
}
Just need to put this file at my root next to webapck.config.js

Resources