The npm command is giving a syntax error: unexpected token (mac) - node.js

I got this msg recently when I tried to use npm
Update available 5.3.0 → 7.11.1 │
│ Run npm i -g npm to update
And so I went ahead and tried to update it and eversince have been getting this error
when I try to use the npm command
/usr/local/lib/node_modules/npm/node_modules/#npmcli/config/lib/index.js:300
...this.defaults,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:9:16)
Any help to fix this will be highly appreciated.
Thanks

The error is showing that node doesn't understand the ... spread syntax.
You should upgrade node to a version that has full support for spread (8.3+).
If possible, you should use the LTS (long-term support) version of node (currently 14.16.1).

Related

Unexpected token issue in truffle on Windows

I am trying to install truffle on node version 8.9.0 and npm version 5.5.1. It got installed but am not able to do anything in that. every time I try any command, even try to unbox it shows an error.
C:\Users\com\AppData\Roaming\nvm\v8.9.0\node_modules\truffle\build\86.bundled.js:55160
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.__webpack_require__.f.require (C:\Users\com\AppData\Roaming\nvm\v8.9.0\node_modules\truffle\build\cli.bundled.js:603:28)
the required node version is Node v12 or later. https://trufflesuite.com/docs/truffle/getting-started/installation/#requirements

vue cli version is not showing

Am trying to run vue.js app for that I have installed vue cli by folliwng the official website("https://cli.vuejs.org/guide/installation.html"). When i execute any vue commands getting below error, I even cant able to check it's version. Is there anything i missied here?
Step1:- npm install -g #vue/cli
Sep2:- vue --version
The npm version is "6.2.0" and nodejs version is "v6.14.3".
andy#ip-172-16-198-195:~/vue/progressive-weather-app$ vue --version
/usr/lib/node_modules/#vue/cli/node_modules/open/index.js:16
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/#vue/cli/node_modules/#vue/cli-shared-utils/lib/openBrowser.js:9:14)
Vue CLI requires Node.js version 8.9 or above (8.11.0+ recommended).
You should update your nodejs version

Error while executing Node registerAdmin.js Blockchain Tuna Fish App

I am trying to execute the tuna fish blockchain app, see below git example
https://github.com/hyperledger/education/tree/master/LFS171x/fabric-material/tuna-app
while running " node registerAdmin.js " I am getting following error
tuna-app/node_modules/fabric-client/lib/Client.js:746
async _createOrUpdateChannel(request, have_envelope) {
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm and node version was quite old. I upgraded the version and error solved
use below command to upgrade NPM & node -
npm install -g npm#latest
npm install -g node
npm rebuild

Yeoman fails to run

I'm on centos 7 and I just installed nodejs version 6.14.3, npm version 3.10.10, and yo version 2.0.5. I then ran the command
yo code
In an attempt to use the yeoman generator to create a vscode extension. I then got the following error:
/usr/lib/node_modules/generator-code/generators/app/index.js:47
async prompting() {
^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.get [as code:app] (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:39:27)
Not sure if I'm just missing a silly dependency or something. Any ideas?
This node version, 6.X, doesn't support asyncs.
Definitely install a newer version, I recommend at least 8.X to not to risk other incompatibilities at the language level.

Error in angular2 cli installation

I am installing angular2 in linux with
sudo npm install -g #angular/cli
and after running that it successifully installs but after typing
ng new mynewapp
Am getting an error
/usr/local/lib/node_modules/#angular/cli/models/config/config.js:16
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/#angular/cli/models/config.js:3:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
what could be wrong
It's seem your nodejs version does not support ES2015, update your node to version 6+
you can using nvm to manage your node version
Your need Node version 6.x or higher
See documentation below
take a look here: https://github.com/angular/angular-cli/issues/4604

Resources