Atyantik/react-pwa

"npm start" is not working

akunal1 opened this issue · 10 comments

while I am trying to run the project I am getting bellow error.

Please note : I have not done any changes to project and I am running code from master branch . I tried with yarn also .
node: 12.19.0v

ERROR:

SyntaxError: D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\watchpack\lib\chokidar.js: 'return' outside of function (4:1)

  2 | try {
  3 |   module.exports = require("chokidar");
> 4 |   return;
    |   ^
  5 | } catch(e) {
  6 |   v3Err = e;
  7 | }
    at Object._raise (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\error.js:60:45)
    at Object.raiseWithData (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\error.js:55:17)
    at Object.raise (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\error.js:39:17)
    at Object.parseReturnStatement (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:563:12)
    at Object.parseStatementContent (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:197:21)
    at Object.parseStatement (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:151:17)
    at Object.parseBlockOrModuleBlockBody (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:871:25)
    at Object.parseBlockBody (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:841:10)
    at Object.parseBlock (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:811:10)
    at Object.parseTryStatement (D:\ResumeBuilder\V03\avinash-resume-pwa\node_modules\@babel\parser\src\parser\statement.js:653:23) {
  loc: Position { line: 4, column: 1 },
  pos: 57,
  code: 'BABEL_PARSE_ERROR'
}

I'm also having the same problem

I have resolved the same issue with writing the chokidar.js file code inside self invocable function.
It may works for you also
(function(){
var v3Err;
try {
module.exports = require("chokidar");
return;
} catch(e) {
v3Err = e;
}

var v2Err;
try {
module.exports = require("watchpack-chokidar2");
return;
} catch(e) {
v2Err = e;
}

throw new Error(
"No version of chokidar is available. Tried chokidar@2 and chokidar@3.\n" +
"You could try to manually install any chokidar version.\n" +
"chokidar@3: " + v3Err + "\n" +
"chokidar@2: " + v2Err + "\n"
)
}())

Have you modified inside node_module ?

Have you modified inside node_module ?

yes because this is dev dependency for windows user and not found for mac user

face the same issue here. is there anyone knows how to solve this problem?

Hopefully this pull request is accepted at some point in watchpack... webpack/watchpack#177

Same for me any solution for this?

I have upgraded the required packages, but with lack of windows system, I am not able to reproduce the issue, Also, I have added code to give priority to Chokidar v3 rather than v2 that solves the issues, please let me know if the issue persists.

try this way, it seem like slove my problem

Obviously, we don't have any interest in waiting for people to 'fix' libraries that return at global scope, so using Jest means I need a way to ignore those.

Here's what I ended up doing:

1.Add a "jest" configuration to file package.json:

  "jest": {
    "transform": {
      "^.+\\.js$": "<rootDir>/.jest.transform.js"
    }
  },

2.Then in the root directory for the project I created file .jest.transform.js and placed this bit to tell Jest to tell Babel to allow return outside of functions:

const babelOptions = {
    parserOpts: {
        'allowReturnOutsideFunction': true
    },
};
module.exports = require('babel-jest').createTransformer(babelOptions);

I hope this helps someone else - I almost walked away from Jest again because of this little nuance!

https://stackoverflow.com/questions/57789431/how-do-i-fix-return-outside-of-function-when-running-a-node-js-application