node.js在执行js文件时出现SystaxError:Unexpected identifier的错误?
来源:互联网 发布:mac 种子下载器 编辑:程序博客网 时间:2024/05/18 15:56
刚学习Node.js,结果刚开始就出现错误了,查询资料,很多都是说写的js脚本有语法错误或者哪里字符串没有用双引号引起来。。但是检查js确定无误,还是这个错误信息。本文以安装目录下的exemple.js为例。
node在安装时分为全局安装和本地安装。出现这种错误主要是安装node时安装在本地中。
1、node全局安装时
1.1>首先打开运行:输入cmd进入控制台
1.2> 输入node D:\Node\安装包文件\node_modules\npm\node_modules\request\node_modules\har-validator\node_modules\is-my-json-valid\example.js (注意:这里的example.js可以直接拖入进cmd控制台窗口)
1.3> example.js中的内容为node中文官网中的例子,大家复制并放入example中即可:
example.js内容为:
const http = require('http');const hostname = '127.0.0.1';const port = 3000;const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n');});server.listen(port, hostname, () => { console.log(`服务器运行在 http://${hostname}:${port}/`);});
2、node本地安装
2.1> 找到node安装目录,复制路径
博主的安装目录为:D:\Node\安装包文件
2.2>打开运行->输入cmd->
因为博主我安装到D盘 路径> D:\Node\安装包文件
大家找到自己node安装的盘符,并且按照博主的上图的操作,即可开启服务。
3、运行网页
3.1 在浏览器中输入127.0.0.1:3000或者http://localhost:3000/ 即可如下效果。
阅读全文
0 0
- node.js在执行js文件时出现SystaxError:Unexpected identifier的错误??
- node.js在执行js文件时出现SystaxError:Unexpected identifier的错误?
- node.js在执行js文件时出现SystaxError:Unexpected token LILEGAL的错误
- JS中Unexpected identifier错误
- Node.js 报语法错误 SyntaxError: Unexpected identifier
- js出现的错误unexpected token
- js异常:Unexpected identifier
- 16-12-30 js里面出现Uncaught SyntaxError: Unexpected identifier错误;
- js文件在导入时出现错误的解决办法
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
- GPIO和门电路
- Linux基础(1)
- 欢迎使用CSDN-markdown编辑器
- ORA-12154:TNS:无法解析指定的连接标识符
- OkHttp 3.7源码分析(四)——缓存策略
- node.js在执行js文件时出现SystaxError:Unexpected identifier的错误?
- Linux进程间通信之管道
- HDU5550
- 射频放大器设计难点
- SuperMap杯全国高校GIS大赛-桌面与组件开发组学习资料
- Qt Post上传图片文件到服务器
- 矩阵快速幂
- OkHttp 3.7源码分析(五)——连接池
- 一个多继承的Python实例