I was working on Node version 9.1.0 but the client asked me to use NVM so that the version can be switched at will. I tried but it was not working. So I uninstalled NodeJS from my windows machine and did a fresh install of NodeJS version 8.9.4
After npm install when I tried to execute the code I got this error:
SyntaxError: Unexpected number
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\inetpub\wwwroot\NodeJS_APIs\api\node_modules\lodash\isFunction.js:1:80)
The line that trew the error is in vm.js:
function createScript(code, options) {
return new Script(code, options);//This is the line
}
I don't understand what went wrong. Can someone please explain what am I doing wrong?
From your error stacktrace it seems the error is related to your loadash library, Can you please try uninstalling it using,
npm uninstall lodash
And then reinstall a compatible lodash version like this,
npm install lodash#4.17.5
Once done, try running your script again.
Hope this helps!
You might get some hints from here, although I’m not sure: https://github.com/rollup/rollup/issues/2054
Related
I'm trying to get an express-graphql app up and running and I've been following the example code from the official documentation. However it keeps crashing and I'm getting this error in my terminal after running npm start.
node_modules/express-graphql/index.js:47
pretty = optionsData.pretty ?? false;
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:1067:16)
at Module._compile (internal/modules/cjs/loader.js:1115:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
Tried to re-install the packages and start over, but I keep getting the same error, what am I missing here?
if you are using version 0.10.0 downgrade it to 0.9.0
npm i express-graphql#0.9.0
This is a bug with the current version of express-graphql. Please use the previous version until a patched version is released.
npm install express-graphql#0.9.0
Edit: This has been fixed in version 0.10.1.
Whenever I try to run nodemon to auto-restart my local server (running on port 3000), I get this error message regarding a syntax error in the no
/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/node_modules/chokidar/index.js:151
async remove(item) {
^^^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/lib/monitor/watch.js:6:16)
at Module._compile (module.js:556:32)
Any way to fix this?
As per my knowledge
Async Await is not available in node v6.5.0,
which you are using. So you can upgrade your node version or can start using Promise object with the same version of node.
In my case, npm list chokidar helped me realize it was another module (gulp-nodemon) that used a newer version of chokidar. It worked after downgrading it.
I had exactly the same error...! it was a node version problem, I was on node version 6, this is what I did to fix it:
nvm install <VERSION_NUMBER> // nvm install 10.15.3
nvm use <VERSION_NUMBER> // nvm use 10.15.3
node -v // confirm i am using the correct version of node
Remember to do this on your computer not just your code file and change the default node version with nvm alias default 10.15.3
you can check your default lists with
nvm list
As I installed electron 8.2 successfully on my linux, I encountered this error while I ran the cli command:
electron .
/usr/local/lib/node_modules/electron/index.js:14
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
^
Error: Electron failed to install correctly, please delete
node_modules/electron and try installing again
at getElectronPath (/usr/local/lib/node_modules/electron/index.js:14:11)
at Object. (/usr/local/lib/node_modules/electron/index.js:18:18)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object. (/usr/local/lib/node_modules/electron/cli.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
Well, it seems the problem is with the usr/local/lib/node_modules/electron folder.
It seemed installed improperly.
So, I copied the node_modules/electron/dist folder in local project and pasted in the global folder mentioned above and :
wooooooooohoooooooooo!!!! solved
I have been working in AngularJS for a while now and I decided to try out Vue. I installed Vue using npm install -g #vue/cli in my terminal using Node version 6.4.0. After the installation was complete I tried creating a new app using vue create <name of app>. It's during this seemingly simple step that I am getting hung up with this error:
/Users/jonalden/.nvm/versions/node/v6.4.0/lib/node_modules/#vue/cli/node_modules/open/index.js:16
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/jonalden/.nvm/versions/node/v6.4.0/lib/node_modules/#vue/cli/node_modules/#vue/cli-shared-utils/lib/openBrowser.js:9:14)
at Module._compile (module.js:556:32)
I have tried downgrading Node to a previous version and reinstalling Vue with Yarn but both were unsuccessful. One thing throwing me off here is the line wslToWindowsPath, which is especially weird since I am on a Mac.
I had the same problem. I've done this :
sudo rm -rf ~/.nvm
I am trying to install heroku CLI using this command "wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh"
Eveything seems to be going at first. But after completition when i type "heroku --version", following error pops up.
/usr/local/lib/node_modules/heroku-cli/bin/run:12
const {run} = require('#cli-engine/engine')
^
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 Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
I don't have any idea how to proceed. I have searched the internet to my capabilities and still unable to find a solution.
I have tried installing using "npm install -g heroku-cli" but still getting the same error.
Any help will be appreciated.
Thanks!
heroku-cli requires a minimum node version of 6.15.24. Upgrade your node. The latest stable version of node is 8.9.4