Cordova 创建项目失败 (cordova create project-name)

问题

在执行命令cordova create project-name时失败,错误消息如下:

Creating a new cordova project.
Unhandled "error" event. (  Error from Cordova Fetch: Error: cmd: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "..\AppData\Roaming\npm\node_modules\cordova\node_modules\_cordova-app-hello-world@3.12.0@cordova-app-hello-world\index.js" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\administrator\AppData\Roaming\npm-cache\_logs\2019-01-11T02_55_02_505Z-debug.log)

解决方法

  1. 打开文件 C:\Users\你的用户名\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\cordova-create\node_modules\cordova-fetch\index.js
  2. 查找代码 fetchArgs.push(target);,然后添加以下代码到这行前面:
if(fs.existsSync(target) && fs.statSync(target).isFile()){
    target = require(target).dirname
}

问题包版本:

  1. cordova: 8.1.2
  2. cordova-app-hello-world: 3.12.0
  3. cordova-create: 1.1.2
  4. cordova-fetch: 1.3.1 其它版本并未进行测试

原因 (胡乱猜的)

打开文件 C:\Users\hyjiacan\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\cordova-create\index.js,查找注释// handle when input wants to specify sub-directory (specified in index.js as "dirname" export);,看看就知道原因了

转载于:https://my.oschina.net/hyjiacan/blog/3000082

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值