本文链接:https://blog.csdn.net/syosinnsya/article/details/80395121
使用brew安装node,首先先对brew进行检查
brew updatebrew doctor如果报这个错:
Warning: Homebrew's s笑点低的蜜粉 was not found in your PATH but you haveinstalledformulae that put executables in /usr/local/s笑点低的蜜粉.Consider setting the PATH for example like soecho 'exportPATH="/usr/local/s笑点低的蜜粉:$PATH"' >> ~/.bash_profile解决方法:
export PATH="/usr/local/笑点低的蜜粉:$PATH"source ~/.bash_profile然后进行安装
brew link nodebrew uninstall nodebrew install node安装node成功。
在使用nodejs时,首先要设置一个工作文件夹,并对其初始化和添加各种dependencies。
创建文件夹后,首先:
npm init//this utility will walk you through createing a package.json file.//it covers the most common items, and tries to guess sane defaults.然后安装各种依赖dependecies,它们会被安装在node_module包里。下面举几个例子。
npm install web3npm install web3-ethnpm install ethereumjs-txnpm install fast-csv语法为:
npm install <module> //安装npm uninstall <module> //卸载npm search <module> //搜索npm update <module> //更新这种安装是本地安装,安装在命令行所在的文件夹里。nodejs使用这些依赖时,要用var xx = requires('xxx')去使用。
还可以全局安装:npm install <module> -g,这种安装方式安装在用户目录下,使用时候不能用require方式。
node install -g 才会把module安装到node全局 不加-g默认安装到当前工程 别的工程不可见。
注:
fs 是node自带的功能,所以不需要npm install fs
npm 是node.js自带的功能
参考文章:
npm init node 通过指令创建一个package.json文件及npm安装package.json
https://blog.csdn.net/qq_35441998/article/details/55270816
【链接】nodejs npm install全局安装和本地安装的区别
https://zhidao.baidu.com/question/1382950329488558500.html
【链接】NPM使用介绍
http://www.runoob.com/nodejs/nodejs-npm.html
还可以全局安装:npm install <module> -g,这种安装方式安装在用户目录下,使用时候不能用require方式。
node install -g 才会把module安装到node全局 不加-g默认安装到当前工程 别的工程不可见。
注:
fs 是node自带的功能,所以不需要npm install fs
npm 是node.js自带的功能
参考文章:
npm init node 通过指令创建一个package.json文件及npm安装package.json
https://blog.csdn.net/qq_35441998/article/details/55270816
【链接】nodejs npm install全局安装和本地安装的区别
https://zhidao.baidu.com/question/1382950329488558500.html
【链接】NPM使用介绍
http://www.runoob.com/nodejs/nodejs-npm.html