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)
Related
Find Visual Studio Code application where I tried to run the file. Things look fine but it says cannot find module. Find my terminal output below along with screenshot in "Node Program"
F:\Git Clone\Node.js_From 31Oct2019\IBM-Developer\Node.js\Course\Unit-6>node server.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'sqlite3'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (F:\Git Clone\Node.js_From 31Oct2019\IBM-Developer\Node.js\Course\Unit-6\utils\utils.js:23:17)
at Module._compile (internal/modules/cjs/loader.js:778:30)
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)
Node Program
You have to run npm i and then restart your application and vs code.
Install NPM by typing npm i and then restart your application
I have run meteor build in one of my meteorJS apps and then extracted the bundle and After running npm install in programs/server
I face an error when I try to run node main.js in root fold
I have tried to search for npm package called topologies to add it but found none
I try to run node main.js but it fails and throws an error
I have expected the app to run but instead I get this error:
node main.js
E:\Projects\elibrary\production\nn\bundle\programs\server\node_modules\fibers\fi
bers.js:90
return fn.apply(this, arguments);
^
Error: Cannot find module ‘…/topologies/read_preference’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (E:\Projects\elibrary\production\nn\bundle\programs\se
rver\npm\node_modules\meteor\npm-mongo\node_modules\mongodb-core\lib\wireprotoco
l\shared.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
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.
I tried to launch first example from official documentation here
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
I used Windows 7x64 bit , node.js 6.11
I tried the following commands and got the same result
*
node_modules/cucumber/bin/cucumber.js autotests/cucumber-test/features/documentation.feature
node_modules\cucumber\bin\cucumber.js autotests\cucumber-test\features\documentation.feature
cucumber autotests\cucumber-test\features\documentation.feature
cucumber-js autotests\cucumber-test\features\documentation.feature
*
and I got the following error
cucumber.js:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
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)
at getDefinitions (<path>\node_modules\cucumber\lib\cucumber\cli\profiles_loader.js:8:23)
I also tried to downgrade to cucumber 1.3.3 but it doesn't help
Please try below command:
node_modules\cucumber\bin\cucumber.js.cmd autotests\cucumber-test\features\documentation.feature
I found solution
1) npm init -> and define package.json
2) npm install cucumber#latest
3) node_modules\.bin\cucumber.js.cmd <path>\myfeature.feature
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