yarn build (serve -s build) causing unexpected identifier - javascript

serve -s build is causing the following error. Why is it an unexpected identifier when it's an argument? Thank you for your help
const updateCheck = async isDebugging => (
^^^^^^^^^^^
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.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
My system is
System Version: macOS 10.13.4 (17E199)
Kernel Version: Darwin 17.5.0
Boot Volume: Macintosh HD
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 5 days 8:33
and I am using
node --version v6.10.3
yarn --version 0.27.5

Updating your node version to the LTS edition will resolve your issue.

Related

Trying to run .mjs script on ZX cmmand line

I tried to run this example on my ubuntu os.
https://github.com/google/zx/blob/main/examples/basics.mjs
after I installed zx from npm
via npm i -g zx
and run the following cmd:
sudo zx ./script.mjs
i got below error:
/usr/local/lib/node_modules/zx/zx.mjs:17
import {basename, dirname, extname, join, parse, resolve} from 'path'
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
My npm version is : 7.14.0
As exlained in above comments:
The issue originated from an old version node that didn't recognize the import feature. which is available only since : v13+ ( see https://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import)

Just installed expo for the first time, get error immediately after initialisation

I am following the steps contained here
https://facebook.github.io/react-native/docs/getting-started
Ive installed a fresh copy of npm and even done npm update command
I then ran npm install -g expo-cli
This gave a whole bunch of warnings about linux packages not installed but im running Windows 10 Home 64bit so no probs there
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: #expo/ngrok-bin-darwin-ia32#2.2.8 (node_modules\expo-cli\node_modules\#expo\ngrok-bin-darwin-ia32):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for #expo/ngrok-bin-darwin-ia32#2.2.8: wanted {"os":"darwin","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
I then typed expo init HelloWorld and got the following error
C:\Users\####\AppData\Roaming\npm\node_modules\expo-cli\node_modules\formidable\lib\incoming_form.js:1
(function (exports, require, module, __filename, __dirname) { �d��.�
^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
Uncaught Error C:\Users\####\AppData\Roaming\npm\node_modules\expo-cli\node_modules\formidable\lib\incoming_form.js:1
(function (exports, require, module, __filename, __dirname) { �d��.�
^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
I have no idea why. Its a clean install, is there something ive missed installing?
used npm install formidable and then copied the resulting folder into the spot where expo has its copy of formidable which has fixed the problem.

Syntax error: Unexpected token ) when building Docusaurus on Node 6

I am encountering an error when running docusaurus build on docusaurus#1.5.1 and Node 6:
$ docusaurus-build
/home/website/node_modules/docusaurus/lib/build-files.js:31
);
^
SyntaxError: Unexpected token )
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.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
Basically there is code like this currently in Docusaurus:
console.log(
chalk.red('hello world'),
);
How do I fix it?
That error occurs because trailing commas in function calls are not supported in older versions of Node. Ensure that you are using a Node version that is 8 and above. As of Docusaurus 1.2.0, Node 6 is not supported anymore and the minimum supported version is Node 8. As stated in the documentation:
You have to be on Node >= 8.x and Yarn >= 1.5.
You could use a tool like nvm to manage your Node versions.

'Invalid flags supplied to RegExp constructor' error when running node server.js for Azure IoT Hub

I am trying to run 'node server.js' to connect my raspberry pi device to Azure via the Azure IoT Hub. When I run the command 'node server.js', I receive the following error. Please note that I replaced my computer's user name with 'username'. The file connection_string.js does not have my computer's username in it, despite the error saying that it does. Please see error below:
SyntaxError: Invalid flags supplied to RegExp constructor '*username*'
at new RegExp (native)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/lib/connection_string.js:9:31)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/common.js:15:21)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/server.js:7:15)
Thank you in advance for your help!
Not sure if it is your case or not, but I had similar issue:
SyntaxError: Invalid flags supplied to RegExp constructor 'u'
I fixed it simply by updating Node.js.
Previous version was:
$ node -v
v5.1.1
Then I did:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
... long output
$ sudo apt-get install -y nodejs
... shorter output
$ node -v
v6.7.0
And no more issues.

Node-Red Pm2 Setup

I am trying to start my node-red on a raspberry pi 2 using pm2. I am using the startup command:
pm2 start /usr/bin/node-red-pi --node-args="--max-old-space-size=128" -- -v
At first it seems to work:
But unfortunatly then it errors:
Thats the log:
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:28:21)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
Please make sure you installed the latest PM2 version (>2.x):
$ npm install pm2#latest -g
$ pm2 update
Then start node-red again, it should works as expected:
pm2 start node-red --node-args="--max-old-space-size=128" -- -v

Categories

Resources