2

Can anyone help me with this SyntaxError? I keep getting it on various paths not only mongoose, sometimes is bluebird sometimes another module.

Tried and deleted the node_modules folder and reinstall the npm modules which fixes the issue but after a couple of runs of the script, it appears again.

I honestly can't explain why it works after reinstalling the node_modules and after a few runs, it doesn't anymore.

Node: v9.8.0 NPM: 5.7.1

node_modules/mongoose/lib/options.js:1
(function (exports, require, module, __filename, __dirname) {


SyntaxError: Invalid or unexpected token
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Module._compile (module.js:613:28)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
  • I have the exact same problem trying to run `node_modules\@nguniversal\express-engine\index.js:1` – Stan Mar 22 '18 at 01:55
  • It's frustrating to reinstall all node_modules after every few runs. The funny thing is that the path where the error is thrown changes. `node_modules/mongodb-core/lib/connection/connection.js:1 (function (exports, require, module, __filename, __dirname) { SyntaxError: Invalid or unexpected token at new Script (vm.js:51:7) at createScript (vm.js:136:10) at Object.runInThisContext (vm.js:197:10) at Module._compile (module.js:613:28) at Object.Module._extensions..js (module.js:660:10) at Module.load (module.js:561:32)` – Ciprian Toma Mar 22 '18 at 08:48

1 Answers1

0

You are having that SyntaxError because you have some broken files in your npm installations probably due to a fluctuation in your internet or any other reason. And you still got that same error after deleting the node_modules folder and re-install the npm modules again because of the same thing I said.

So your problem got fixed that last time because after you re-installed all the required dependencies ere fully installed in your node_modules.

antzshrek
  • 9,276
  • 5
  • 26
  • 43