一、问题: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
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐