Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React js SyntaxError Occurs in Node Modules webpack chokidar.js 'return' outside of function (4:2)

I am facing this issue from last day.. No solution for this error Complete error log is mentioned below

var v3Err;
try {
    module.exports = require("chokidar");
    return;
} catch(e) {
    v3Err = e;
}
      

Error occurs in 'return' outside of function (4:2)

SyntaxError: E:\test\node_modules\watchpack\lib\chokidar.js: 'return' outside of function (4:2)

at Object._raise (E:\test\node_modules@babel\parser\src\parser\error.js:60:45) at Object.raiseWithData (E:\test\node_modules@babel\parser\src\parser\error.js:55:17) at Object.raise (E:\test\node_modules@babel\parser\src\parser\error.js:39:17) at Object.parseReturnStatement (E:\test\node_modules@babel\parser\src\parser\statement.js:563:12) at Object.parseStatementContent (E:\test\node_modules@babel\parser\src\parser\statement.js:197:21) at Object.parseStatement (E:\test\node_modules@babel\parser\src\parser\statement.js:151:17) at Object.parseBlockOrModuleBlockBody (E:\test\node_modules@babel\parser\src\parser\statement.js:873:25) at Object.parseBlockBody (E:\test\node_modules@babel\parser\src\parser\statement.js:843:10) at Object.parseBlock (E:\test\node_modules@babel\parser\src\parser\statement.js:813:10) at Object.parseStatementContent (E:\test\node_modules@babel\parser\src\parser\statement.js:218:21) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: pawjs --no-cache --config=./pawconfig.json --env=development start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\glowlogix\AppData\Roaming\npm-cache_logs\2020-08-17T09_19_41_742Z-debug.log

like image 993
jawad zahoor Avatar asked Aug 17 '20 09:08

jawad zahoor


People also ask

Why can’t I import other modules in Node JS?

Because Node.js uses CommonJS syntax (require syntax) to import other modules/functions. Whereas, the import syntax is called ES modules, which is a standard in JavaScript. Now we understand the issue, let's see how to fix it.

How do I use WebPack with ReactJS?

In order to use Webpack with ReactJS.NET's server-side rendering, it is suggested that you create a separate bundle ("entry point") containing only the code required to perform server-side rendering. Any components you would like to render server-side must be exposed globally so that ReactJS.NET can access them.

What is the best way to bundle react and ReactJS?

Webpack is the recommended bundling solution and should be preferred over Cassette or ASP.NET Bundling. Your project will bundle its own copy of react and react-dom with webpack, and ReactJS.NET will be used only for server-side rendering.

Where can I find an example of a ReactJS asset manifest?

A full example is available in the ReactJS.NET repository. An asset manifest is generated by the webpack-asset-manifest plugin, written to asset-manifest.json. See the webpack config example above for details on how to set this up. This manifest file contains a list of all of the bundles required to run your app.


1 Answers

I was facing the same problem in my project. An autocomplete (due to a typo) automatically added an import to my file. When i removed it my problem was solved. So i advice you to check your modules for unnecessary imports.

example of my auto added import

like image 144
cyclomatic_complexity Avatar answered Sep 30 '22 03:09

cyclomatic_complexity