Atyantik / react-pwa

An upgradable boilerplate for Progressive web applications (PWA) with server side rendering, build with SEO in mind and achieving max page speed and optimized user experience.
https://www.reactpwa.com
MIT License
2.57k stars 302 forks source link

"npm start" is not working #196

Closed akunal1 closed 3 years ago

akunal1 commented 4 years ago

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'
}
p32929 commented 4 years ago

I'm also having the same problem

tirthbodawala commented 4 years ago

Apologies, I am a bit occupied as of now, I am aware of the issue on Windows. I will look into it this weekend.

On Sun, Oct 18, 2020 at 8:47 PM akunal1 notifications@github.com wrote:

I'm also having the same problem

If you are looking for installable simple react JS PWA with typescript , have a look into : https://github.com/akunal1/react-js-typescript-boilerplate-pwa

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Atyantik/react-pwa/issues/196#issuecomment-711214177, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWDN772S3VJITGL2LRY47DSLMBILANCNFSM4SQRXXNA .

-- Tirth Bodawala Founder Atyantik Technologies w: www.atyantik.com e: tirthbodawala@atyantik.com

amarshahaji commented 4 years ago

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" ) }())

akunal1 commented 4 years ago

Have you modified inside node_module ?

amarshahaji commented 4 years ago

Have you modified inside node_module ?

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

bryanltobing commented 3 years ago

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

jeffwilcox commented 3 years ago

Hopefully this pull request is accepted at some point in watchpack... https://github.com/webpack/watchpack/pull/177

sunilhari9 commented 3 years ago

Same for me any solution for this?

tirthbodawala commented 3 years ago

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.

946629031 commented 2 years ago

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