android 模拟器安装nodejs
1. 下载二进制包:https://github.com/sjitech/nodejs-android-prebuilt-binaries/blob/master/nodejs-7.7.2-android-x86-full/all.7z
2. 将其解压,转换成zip文件上传到模拟器
1 | adb push ~ /Downloads/all .zip /mnt/shared/NoxShare/ |
3. 在模拟器中解压:unzip all.zip
4. 拷贝node相关东东到相应目录
1 2 | cp /mnt/shared/NoxShare/all/lib/node_modules/ /system/lib/ cp /mnt/shared/NoxShare/all/bin/node /system/xbin/ |
5. 创建软连接
1 2 | cd /system/xbin/ ln -s .. /lib/node_modules/npm/bin/npm-cli .js npm |
6. 尝试执行npm
如果报错:/system/xbin/npm: No such file or directory, 那么修改 ../lib/node_modules/npm/bin/npm-cli.js 的第一行:
1 2 3 | vi npm 将第一行 修改为 #!/system/xbin/node 保存退出 |
7. 查看node,npm状态:
8. 基础安装完毕, 安装npm i -g express
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | npm ERR! Linux 4.0.9+ npm ERR! argv "/system/xbin/node" "/system/xbin/npm" "i" "-g" "express" npm ERR! node v7.7.2 npm ERR! npm v4.1.2 npm ERR! path /.npm npm ERR! code EROFS npm ERR! errno -30 npm ERR! syscall mkdir npm ERR! rofs EROFS: read -only file system, mkdir '/.npm' npm ERR! rofs This is most likely not a problem with npm itself npm ERR! rofs and is related to the file system being read -only. npm ERR! rofs npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error. npm ERR! Linux 4.0.9+ npm ERR! argv "/system/xbin/node" "/system/xbin/npm" "i" "-g" "express" npm ERR! node v7.7.2 npm ERR! npm v4.1.2 npm ERR! path npm-debug.log.2776577660 npm ERR! code EROFS npm ERR! errno -30 npm ERR! syscall open npm ERR! rofs EROFS: read -only file system, open 'npm-debug.log.2776577660' npm ERR! rofs This is most likely not a problem with npm itself npm ERR! rofs and is related to the file system being read -only. npm ERR! rofs npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error. npm ERR! Please include the following file with any support request: npm ERR! /npm-debug .log |
错误很明显,没有根目录的操作权限。
解决思路: /.npm 是只读导致的。 思路就是换到 /mnt/shared/NoxShare/.npm
在npm库中找到核心代码:
几个默认的值:
npm config set cache xxxxx 会报:/.npmrc 无权限
npm config set userconfig xxx 会报 /.npmrc 无权限
也就是npm config set一定会操作.npmrc。 太扯了。
npm --userconfig=/mnt/shared/NoxShare/.npmrc 命令设置成功,但是安装express还是失败
得出结论,无论如何都修改不了npm的配置。不能改HOME的环境变量,因为担心会引发其他问题。那就改代码吧。
vi /system/xbin/npm
改完后装成功了:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构