2

npm start works fine in intellij's terminal.

But it fails at the below line when run in regular shell terminal

 const {
   choosePort,
   createCompiler,
   prepareProxy,
   prepareUrls,
 } = require('react-dev-utils/WebpackDevServerUtils');

The code above is inside start.js and npm start runs node start.js

I guess intellij somehow uses es6 by default.
How can I mimic that outside of intellij?

Below is the error

$ npm start

> bold-chat-admin@0.1.0 start /Users/eugenekim/Documents/boldchatting.web
> PORT=3000 node scripts/start.js

/Users/eugenekim/Documents/boldchatting.web/scripts/start.js:23
const {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
    at node.js:999:3

npm ERR! Darwin 17.3.0
npm ERR! argv "/Users/eugenekim/.nvm/versions/node/v5.5.0/bin/node" "/Users/eugenekim/.nvm/versions/node/v5.5.0/bin/npm" "start"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! bold-chat-admin@0.1.0 start: `PORT=3000 node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bold-chat-admin@0.1.0 start script 'PORT=3000 node scripts/start.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bold-chat-admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     PORT=3000 node scripts/start.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls bold-chat-admin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/eugenekim/Documents/boldchatting.web/npm-debug.log
eugene
  • 39,839
  • 68
  • 255
  • 489

1 Answers1

0

IDEA itself doesn't run the code - it's run with Node.js interpreter you have chosen in your NPM run configuration (usually the same as set in Preferences | Languages & Frameworks | Node.js and NPM, unless you choose a different one explicitly). Looks as if the Node.js interpreter you use for running your scripts in IDEA supports ES6 destructuring natively, whereas node 5.5 used in terminal doesn't. See http://node.green/ for information about ES6 featurtes supported in different Node versions

lena
  • 90,154
  • 11
  • 145
  • 150