最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why do I get a "SyntaxError: Unexpected identifier" error when I use the Node.js Interactive Wind

programmeradmin0浏览0评论

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 remended version of Node.js (currently v6.11.1).

From a mand 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 mand 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?

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 remended version of Node.js (currently v6.11.1).

From a mand 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 mand 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?

Share Improve this question asked Jul 21, 2017 at 19:43 jlavalletjlavallet 1,3751 gold badge12 silver badges38 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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 ment on this) the npm mand must be prefixed with a dot like this:

.npm install -g nsp

I find this pletely nonintuitive, but it solved my problem. I hope this will help someone else.

The NPM mand must be prefixed with a dot and I am doing the same in my local machine' VS 2013's Node application. It is working for me when adding dot as prefix.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论