首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏acoolgiser_zhuanlan

    node.js中“模块”Module的概念和介绍

    例如下面的hello.js文件就是一个模块,模块的名字就是文件名(去掉.js后缀),所以hello.js文件就是名为hello的模块。 我们在hello.js文件中创建一个函数,这样我们就可以在其他地方调用这个函数: hello.js: 'use strict'; var s = 'Hello'; function greet(name 其实变量greet就是在hello.js中我们用module.exports = greet;输出的greet函数。 ; Node.js加载了hello.js后,它可以把代码包装一下,变成这样执行: (function () { // 读取的hello.js代码: var s = 'Hello'; 练习 编写hello.js,输出一个或多个函数; 编写main.js,引入hello模块,调用其函数。

    1.3K20发布于 2019-01-17
  • 来自专栏ops技术分享

    Node.js模块系统(上)

    /hello') 引入了当前目录下的 hello.js 文件(./ 为当前目录,node.js 默认后缀为 js)。 接下来我们就来创建 hello.js 文件,代码如下: exports.world = function() { console.log('Hello World'); } 在以上示例中,hello.js /hello') 加载这个模块,然后就可以直接访 问 hello.js 中 exports 对象的成员函数了。 有时候我们只是想把一个对象封装到模块中,格式如下: module.exports = function() { // ... } 例如: //hello.js function Hello() {

    1.2K20发布于 2021-07-12
  • 来自专栏人生代码

    webpack打包原理入门探究(一)

    /hello.js": /*!******************!*\ !*** ./hello.js ***! \******************/ /*! /hello.js?") 加载第二个 world.js world.js 代码如下 console.log("world") hello.js 代码如下 require('. /hello.js": /*!******************!*\ !*** ./hello.js ***! \******************/ /*! ; /***/ }) 第六:那其实我想看看如果在 hello.js 直接引入 style.css 会发生什么?

    54120发布于 2020-06-02
  • 来自专栏软件

    nodejs的引用和导出

    正如我们想的那样,nodejs每次只能运行一个js脚本,所以如果想运行多个js脚本可以采用引用(require)的方式 // index.js console.log('这个是 index.js') // hello.js console.log('这个是 hello.js') require('. /index') // 运行 $ node hello.js 那如何调用index.js中的属性和方法呢? 这个时候就需要导出这些属性和方法 // index.js exports.name = '张三' exports.add = function (x, y){ return x + y } // hello.js

    95540发布于 2021-08-10
  • 来自专栏上善若水

    PJS001 PhantomJ简易入门

    第一个小程序HelloWorld 编辑新建hello.js文件,输入内容如下: //a phantomjs example var page = require('webpage').create(); } phantom.exit(0); } ); 在cmd命令行下运行 λ phantomjs.exe D:\Users\Frank\Desktop\PhantomJS\hello.js 例如我们第一个程序的执行命令如下: phantomjs hello.js 打开debug模式(该模式用于开发,可提供必要提示信息): phantomjs --debug=yes hello.js 设置cookie 路径: phantomjs --cookie-file=cookie.txt hello.js 参考链接 PhantomJS快速入门

    74320发布于 2018-09-28
  • 来自专栏前端导学

    linux下node.js安装配置

    #--------------------测试---------------------------- #创建nodejs项目目录 mkdir -p /usr/local/nodejs/ #创建hello.js 文件 vi /usr/local/nodejs/hello.js #内容如下: var http = require("http"); http.createServer(function(request ; #后台运行 node /usr/local/nodejs/hello.js & #浏览器访问 http://192.168.2.2:8100/

    1.2K10发布于 2019-05-26
  • 来自专栏全栈工程师修炼之路

    Nodejs入门学习1.md

    > Demo() module.exports.hello = hello //#主调用文件moduel.js //在使用require()引入模块的时候,请注意模块的相对路径,因为main.js和hello.js /src/greeting.js') Demo.hello() //Hello ~ 案例2:自定义模块 //########## src\hello.js ########### //hello.js /src/hello'); var s = 'WeiyiGeek'; //成功地引用了hello.js模块中定义的greet()函数 greet(s); // Hello, WeiyiGeek!

    59820发布于 2020-10-23
  • 来自专栏Fundebug

    Source Map入门教程

    下面是一个简单的“hello World”程序hello.js function sayHello() { var name = "Fundebug"; var greeting = " Hello, " + Name; console.log(greeting); } sayHello(); 使用UglifyJS2对源代码进行压缩变换: uglifyjs hello.js \ /hello.js:4:9 <匿名> file:///Users/fundebug/sourcemap-tutorial/hello.js:8:1 而hello.min.js的报错信息是这样: ReferenceError 使用UglifyJS2时指定source-map选项即可生成Source Map: uglifyjs hello.js \ -m toplevel=true \ -c :4) at hello.js:8 注意,Chrome的报错信息没有列号,因此4为错误的行号。

    1.5K60发布于 2018-09-17
  • 来自专栏前端导学

    GraphQL入门

    mkdir graphqljs cd graphqljs npm init npm install --save graphql touch hello.js 编辑hello.js var { graphql

    67520编辑于 2022-03-24
  • 来自专栏云计算教程系列

    在腾讯云CVM上安装熟悉Node.js

    在本教程中,我们将使用nano编辑一个名为的示例应用程序:hello.js cd ~ nano hello.js 将以下代码插入文件中。 测试应用 要使我们能够测试应用程序,请标记可执行文件:hello.js chmod +x ./hello.js 并运行它: . 开始 您要做的第一件事是使用pm2 start命令在后台运行您的应用程序:hello.js pm2 start hello.js 你的应用程序应该已经启动了,接下来我们看看会输出什么 [PM2] Spawning 反过来,这个pm2实例运行hello.js。 假设我们的服务器ip解析到example.com上,通过Web网络浏览器访问http://example.com/会发送请求到hello.js,侦听 本地主机的 8080端口。

    7.4K50发布于 2018-07-12
  • 来自专栏前端时刻

    webpack打包原理 ? 看完这篇你就懂了 !

    /hello.js': './src/hello.js' }, code: '"use strict";\n\nvar _hello = require(". /hello.js");\n\ndocument.write((0, _hello.say)("webpack"));' }, '. /hello.js': './src/hello.js' }, code: '"use strict";\n\nvar _hello = require(". /hello.js': './src/hello.js' }, code: '"use strict";\n\nvar _hello = require(". /hello.js': './src/hello.js' }, code: '"use strict";\n\nvar _hello = require(".

    1.5K20发布于 2020-03-02
  • 来自专栏Java小技巧

    Java 8 新特性|Nashorn JavaScript

    创建一个 JavaScript 文件 hello.js ,然后输入以下内容 print("你好,二哥!") ; JJS命令执行 gedeMacBook-Pro:test sunjiahao$ jjs hello.js 你好,二哥! 12 Process finished with exit code 0 六、在 JavaScript 中调用 Java 代码 创建一个 hello.js 文件,然后... var BigDecimal result = calculate(568000000000000000023,13.9); print(result); 运行结果: gedeMacBook-Pro:test sunjiahao$ jjs hello.js

    1.2K20编辑于 2022-05-23
  • 来自专栏杰的记事本

    强类型 JavaScript方案 Typescript & flow

    // hello.js /* @flow */ function foo(x) { return x*10; } foo("Hello, world!") ; 上面是文件 hello.js ,该文件的第一行是注释,表明需要使用 Flow 检查变量类型。 $ flow check hello.js:7:5,19: string This type is incompatible with /hello.js:4:10,13: number 运行 flow

    1.2K10发布于 2019-09-04
  • 来自专栏云计算教程系列

    如何在Ubuntu 16.04上设置Node.js生产应用程序

    在本教程中,我们将使用nano编辑一个名为hello.js的示例应用程序: cd ~ nano hello.js 将以下代码插入文件中。 测试应用 为了测试您的应用程序,请标记hello.js可执行文件: chmod +x ./hello.js 并运行它: . 开始申请 您要做的第一件事是使用pm2 start命令在后台运行您的应用程序hello.js: pm2 start hello.js 这也将您的应用程序添加到PM2的进程列表中,每次启动应用程序时都会输出该列表 这个pm2实例反过来就是运行hello.js。 假设我们的服务器可在example.com可用,通过网络浏览器访问https://example.com/会发送请求到hello.js,侦听端口8080的本地主机。

    2.9K00发布于 2018-10-17
  • 来自专栏云计算教程系列

    如何在Ubuntu 18.04上配置Node.js生产环境应用

    首先,让我们创建一个名为hello.js的示例应用程序: $ cd ~ $ nano hello.js 将以下代码插入到文件中: 〜/ hello.js const http = require('http 让我们首先使用该pm2 start命令在后台运行您的hello.js应用程序: $ pm2 start hello.js 这也将您的应用程序添加到PM2的进程列表中,每次启动应用程序时都会输出该列表: daemon with pm2_home=/home/sammy/.pm2 [PM2] PM2 Successfully daemonized [PM2] Starting /home/sammy/hello.js 反过来,这个pm2将实例地运行hello.js。 假设我们的服务器在example.com上可用,通过Web浏览器访问https://example.com/会将请求发送到hello.js,在localhost上侦听端口3000。

    3.9K30发布于 2018-07-23
  • 来自专栏阮一峰的网络日志

    强类型 JavaScript 的解决方案

    // hello.js /* @flow */ function foo(x) { return x*10; } foo("Hello, world!") ; 上面是文件 hello.js ,该文件的第一行是注释,表明需要使用 Flow 检查变量类型。 $ flow check hello.js:7:5,19: string This type is incompatible with /hello.js:4:10,13: number 运行 flow

    1.2K50发布于 2018-04-12
  • 来自专栏软件

    nodejs的引用和导出

    正如我们想的那样,nodejs每次只能运行一个js脚本,所以如果想运行多个js脚本可以采用引用(require)的方式 // index.js console.log('这个是 index.js') // hello.js console.log('这个是 hello.js') require('. /index') // 运行 $ node hello.js 那如何调用index.js中的属性和方法呢? 这个时候就需要导出这些属性和方法 // index.js exports.name = '张三' exports.add = function (x, y){ return x + y } // hello.js

    85030发布于 2021-06-24
  • 来自专栏java大数据

    html当中如何引用js文件

    例 1.2 <html> <head> <script src="<em>Hello.js</em>"></script> <title></title> </head> <body> </body> </html> Hello.js(如果你用notepad建立一个txt之后你再改为js,一定在存时,要存成utf-8或unicode格式): var a ; /*before you

    11.8K00发布于 2019-10-04
  • 来自专栏全栈程序员必看

    Hello, Webpack!

    打包第一个文件 用编辑器打开项目,新建一个hello.js文件。 使用webpack打包hello.js文件,同样,不是全局安装webpack的小伙伴们这时得注意路径问题了。 // 全局安装webpack的情况 webpack hello.js bundle.js // 非全局安装webpack的情况 cd node_modules/.bin webpack [完整路径]/hello.js 修改package.json文件,在scripts属性中新增执行webpack打包的脚本,比如build,执行npm run build hello.js bundle.js,发现打包成功。 新建一个index.html文件和style.css文件,在样式文件中添加一些样式,并在hello.js文件里用require的方式将其引入(require是CommonJS的语法,webpack支持CommonJS

    36420编辑于 2022-07-20
  • 来自专栏oracle3技术大杂烩

    2021-01-26 quickjs在windows编译

    quickjs选择的是cpp包装:https://github.com/ftk/quickjspp 参考Clion 2016.3.4 + tdm-gcc 安装教程 安装clion和tdm-gcc最新版 测试hello.js 使用clion打开quickjspp目录,选择cmake项目,然后需要在run-->edit configures修改如下: qjs配置 其中hello.js来自https://github.com

    1.4K20编辑于 2022-04-22
领券