I'm new to Node.js and npm and I'm trying to configure a JavaScript development environment in Visual Studio 2017. I have downloaded and installed the latest recommended version of Node.js (currently v6.11.1).
From a command prompt I verified that my Node.js path is configured correctly and that I am pointing at the expected version. To do this I ran:
node -v
and as expected I got back:
v6.11.1
I also configured Visual Studio to use this version. To do that I went to Tools > Options, added the Node.js root folder to my list of External Web Tools, and moved the path to the top of the list as you see in the following screenshot.
I have verified that the Visual Studio tooling is in fact using this version by modifying my package.json file and verifying that the packages have downloaded. Here is a screenshot showing that:
I also launched the Node.js Interactive Window directly from my project node as is shown in the screenshot below:
But when I try to run an npm command from the interactive window I get a "SyntaxError: Unexpected identifier" error like the screenshot below:
So my question is – Why do I get a "SyntaxError: Unexpected identifier" error?
To solve the "Uncaught SyntaxError: Unexpected identifier" error, make sure you don't have any misspelled keywords, e.g. Let or Function instead of let and function , and correct any typos related to a missing or an extra comma, colon, parenthesis, quote or bracket.
"Unexpected identifier" means that you have a variable you're trying to reference that hasn't been declared. Make sure you pass all the variables you're trying to use into your template. All reactions.
The error “npm is not recognized as an internal or external command” error may occur because either the npm is not installed or it is not added to the windows path. To resolve this error, the first solution is to install Node. js on Windows as Node. js is equipped with npm by default.
As I was just finishing up this question I was able to speak with a colleague who said that he ran across the same problem. For some strange reason (maybe some of you experts can comment on this) the npm command must be prefixed with a dot like this:
.npm install -g nsp
I find this completely nonintuitive, but it solved my problem. I hope this will help someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With