Mobilefirst 8-将浏览器平台添加到cordova项目时出现错误“cp:dest file no such file or directory”

Posted

技术标签:

【中文标题】Mobilefirst 8-将浏览器平台添加到cordova项目时出现错误“cp:dest file no such file or directory”【英文标题】:Mobilefirst 8 - getting error "cp: dest file no such file or directory" while adding browser platform to cordova project 【发布时间】:2017-11-29 07:37:05 【问题描述】:

我使用带有 mfp 模板的 CLI 创建了 cordova mobilefirst 8 应用程序。 遵循以下命令

多功能一体机版本:8.0.0.00-20171024-121931

cordova create Hello com.example.helloworld HelloWorld --template cordova-template-mfp

cd Hello

cordova platform add browser

添加浏览器平台时出现以下复制错误:

cp: dest file no such file or directory: D:\Projects\Mobilefirst\HelloCordova\Hello\platforms\browse
r\platform_www\plugins\cordova-plugin-mfp\worklight\analytics

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\ibmmfpf.js

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\typings

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\node_modules\express

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\node_modules\request

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\node_modules\jssha

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\node_modules\promiz

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\node_modules\sjcl

cp: copyFileSync: could not write to dest file (code=ENOENT):D:\Projects\Mobilefirst\HelloCordova\He
llo\platforms\browser\platform_www\plugins\cordova-plugin-mfp\worklight\proxy.js

其展示平台已成功添加到应用中。我也将应用程序注册到 MFP。

在浏览器上运行时出现错误。

cordova run browser

D:\Projects\Mobilefirst\HelloCordova\Hello>cordova run browser
module.js:471
    throw err;
    ^

Error: Cannot find module 'D:\Projects\Mobilefirst\HelloCordova\Hello\platforms\browser\www\plugins\
cordova-plugin-mfp\worklight\proxy.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3
startPage = index.html
Static file server running @ http://localhost:8000/index.html
CTRL + C to shut down
Error: exit code 1

请建议我们如何解决此问题。除此之外,我们还需要做些什么吗?

【问题讨论】:

我无法重现该问题。您正在运行什么版本的 Cordova?此外,消息显示“无法写入目标文件”。您是否正在处理写入权限问题? 请检查安装的版本为: Cordova : 7.1.0 npm: 5.5.1 node : 6.11.0 We are using windows. 您对文件夹有写权限吗?你能以管理员身份运行命令吗? @Srik 是的,我正在以管理员身份运行命令。我发现帖子说最新版本的cordova-browser 5.0.0和cordova 7.1.0有问题。 issues.apache.org/jira/browse/CB-13228 他们应用了修复,但问题仍然存在。 【参考方案1】:

我按照您提供的步骤进行了尝试,我可以看到我的应用程序在 http://localhost:9081/HelloWorld/ 成功运行

唯一的区别是我在添加浏览器时看到了这个

sudo cordova platform add browser
Adding browser project...
Running command: /Users/manjuk/.cordova/lib/npm_cache/cordova-
browser/4.1.0/package/bin/create /Users/manjuk/Hello/platforms/browser 
com.example.helloworld HelloWorld
Creating Browser project. Path: platforms/browser
Discovered plugin "cordova-plugin-mfp" in config.xml. Adding it to the 
project
Fetching plugin "cordova-plugin-mfp@~8.0" via npm
Installing "cordova-plugin-mfp" for browser
Fetching plugin "cordova-plugin-device" via npm
Installing "cordova-plugin-device" for browser
Fetching plugin "cordova-plugin-dialogs" via npm
Installing "cordova-plugin-dialogs" for browser
Fetching plugin "cordova-plugin-globalization" via npm
Installing "cordova-plugin-globalization" for browser
***The run script is being replaced to suppress cordova's default 
 browser.***
If you made changes to your run script(in cordova folder), manually 
merge 
run.bak with the run script that is provided with IBM MobileFirst 
Platform Foundation
Discovered plugin "cordova-plugin-splashscreen" in config.xml. Adding 
it 
to the project
Fetching plugin "cordova-plugin-splashscreen@~3" via npm
Installing "cordova-plugin-splashscreen" for browser
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it 
to 
the project
Fetching plugin "cordova-plugin-whitelist@~1" via npm
Installing "cordova-plugin-whitelist" for browser

【讨论】:

你能在windows上试试吗?另外能否请您提及您使用的 MFP、cordova、npm 版本是什么版本? npm-3.10.10,cordova-6.5.0,mfpdev-8.0.0-2017012016 .【参考方案2】:

可以使用 npm 版本:3.10.10

在您的情况下,这清楚地表明您处于代理之下。

【讨论】:

以上是关于Mobilefirst 8-将浏览器平台添加到cordova项目时出现错误“cp:dest file no such file or directory”的主要内容,如果未能解决你的问题,请参考以下文章

Mobilefirst 平台处理客户端事件

Windows 8.1 64 位中的 IBM MobileFirst 平台安装

现有 IONIC 1 项目迁移到 IBM Worklight(MobileFirst 平台“MFP”)

将 Android 环境添加到 IBM MobileFirst Shell 组件

MobileFirst 8.0 查看远程服务器上应用程序的浏览器版本?

将 MobileFirst JavaScript 适配器从 7.1 升级到 8.0 时替换轮询事件源