admin 管理员组文章数量: 887006
1.下载镜像【WIN7用户看这里】
2.默认安装完毕后,创建node_global&node_cache文件夹
补充:它默认是存储在C:\Users\ROOT\AppData\Roaming的
3.修改默认环境
npm config set prefix "C:\Program Files\nodejs\node_global"
npm config set cache "C:\Program Files\nodejs\node_cache"
4.环境变量(NODE_PATH)
修改用户变量的npm路径C:\Program Files\nodejs\node_global
5.安装全局文件
npm install webpack -g
补充:有的同学可能会报错哈
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/webpack: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'
npm ERR! at C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR! at async Arborist.[nodeFromEdge] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1082:19)
npm ERR! at async Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:951:11)
npm ERR! at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:215:7)
npm ERR! at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:152:5)
npm ERR! at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR! at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5)
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/webpack: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'
npm ERR! at C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR! at async Arborist.[nodeFromEdge] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1082:19)
npm ERR! at async Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:951:11)
npm ERR! at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:215:7)
npm ERR! at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:152:5)
npm ERR! at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:157:5)
npm ERR! at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5) {
npm ERR! code: 'EPERM',
npm ERR! errno: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache',
npm ERR! type: 'system',
npm ERR! requiredBy: '.'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
是因为当前用户没权限写入文件夹
- 解决方案一:
给一下权限就OK了
- 解决方案二:
写入完成
查看webpack版本
6.设置镜像
npm config get registry # 查看当前镜像库
npm config set registry https://registry.npmmirror.com --global # 设置全局淘宝镜像
npm config set registry https://registry.npmmirror.com # 切换回默认地址
npx nrm use taobao # 切换到淘宝源
npx nrm use npm # 切换到官方
- 安装cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm -v # 查看版本
npm list -g # 查看全局安装的模块
npm list vue # 查看某个模块的版本号
npm install sass-node@x.x.x # 安装提定版本包
npm update sass-node # 更新到最新版的包
npm uninstall jquery # 卸载包
7.执行报错
Error while executing: npm ERR! D:\Program Files\Git\cmd\git.EXE ls-remote -h -t git://github.com/ad
npm config set registry https://registry.npmmirror.com
# 使用淘宝镜像安装即可
npm install --registry=https://registry.npm.taobao.org
版权声明:本文标题:Windows搭建Nodejs【全网最详细】 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1734802607h1670545.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论