Cordova create project error 解决方法

来源:互联网 发布:mysql 语句编写 编辑:程序博客网 时间:2024/06/11 16:51

使用npm安装cordova,然后使用cordova create oo报错

Error: Uncaught, unspecified "error" event. (  Error from Cordova Fetch: Error:cmd: Command failed with exit code 4294963238 Error output:npm ERR! not a package C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\.3.12.0@cordova-app-hello-world\index.jsnpm ERR! addLocal Could not install C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\.3.12.0@cordova-app-hello-world\index.jsnpm ERR! Windows_NT 6.1.7601npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\cordova\\node_modules\\.3.12.0@cordova-app-hello-world\\index.js"npm ERR! node v6.10.1npm ERR! npm  v3.10.10npm ERR! path C:\Users\ADMINI~1\AppData\Local\Temp\npm-5648-2836ec66\unpack-bfff7e3c\package.jsonnpm ERR! code ENOENTnpm ERR! errno -4058npm ERR! syscall opennpm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\ADMINI~1\AppData\Local\Temp\npm-5648-2836ec66\unpack-bfff7e3c\package.json'npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\ADMINI~1\AppData\Local\Temp\npm-5648-2836ec66\unpack-bfff7e3c\package.json'npm ERR! enoent This is most likely not a problem with npm itselfnpm ERR! enoent and is related to npm not being able to find a file.npm ERR! enoentnpm ERR! Please include the following file with any support request:npm ERR!     C:\Users\Administrator\.cordova\node_modules\npm-debug.log)

npm version: 3.10.10,出错原因没有深究。

解决方法:

  1. 卸载cordova
  2. 安装 yarn
  3. 私用yarn的淘宝镜像
  4. yarn 全局安装cordova

代码如下:

npm uninstall -g cordova npm install -g yarnyarn config set registry https://registry.npm.taobao.orgyarn global add cordova

猜测可能是和npm新版不兼容,yarn是一个由Facebook发布的包管理器,完全可以替代npm。希望这篇文章能帮助到你

阅读全文
0 0
原创粉丝点击