uni-app 安装node_module模块
Posted wangmj518
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uni-app 安装node_module模块相关的知识,希望对你有一定的参考价值。
一、问题:uni-app 开发中调用uni的方法是控制台报错,Module build failed (from ./node_modules/babel-loader/lib/index.js
1,本地安装node ---
2,以管理员身份打开cmd命令工具,进入项目的文件夹下,执行
npm install @babel/core @babel/preset-env
注意:如果不是管理员身份打开 cmd 时常会出现错误,请以管理员身份打开cmd。
3,uni-app项目重新启动,就可以使用uni的工具,参考接口文档
https://uniapp.dcloud.io/api/file/file?id=savefile
二、npm ERR!报错
npm执行清理缓存失败npm cache clean
C:\\Users\\you name>npm cache clean
npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use `npm install --cache /tmp/empty-cache` to use a temporary cache instead of nuking the actual one.
npm ERR!
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\\Users\\you name\\AppData\\Roaming\\npm-cache\\_logs\\2019-05-12T07_07_25_826Z-debug.log
解决方案 由于 npm 5 使用了新的包管理模式,所以在升级之后,请先清空一下本地缓存:
npm cache clean --force 。
如果上边没办法解决问题,可以尝试下边的指令:
npm cache clear --force && npm install --no-shrinkwrap --update-binary
三、npm install报错ERR! code ETIMEDOUT的解决办法
使用 npm install 安装组件报错:
D:\\vue>w3h5>npm i cnpm -g npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/graceful-readlink failed, reason: connect ETIMEDOUT 104.16.25.35:443 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm ERR! A complete log of this run can be found in: npm ERR! C:\\Users\\Deshun\\AppData\\Roaming\\npm-cache\\_logs\\2020-06-01T03_09_36_539Z-debug.log
在网上查了一下,找到解决方法:
执行下面两行代码,清除代理和缓存,问题解决。
npm config set proxy false npm cache clean
以上是关于uni-app 安装node_module模块的主要内容,如果未能解决你的问题,请参考以下文章
无法安装 Web3(未找到模块:./node_modules/web3/lib/index.js)
为啥我创建的 npm 包在安装它作为另一个模块的依赖项时有一个 node_modules 文件夹?
无法使用电子读取 /node_modules/bindings/bindings.js 处未定义的属性“模块”并安装串行端口