【问题标题】:Cordova on Mac OSX: issues with a network project folder (Windows)Mac OSX 上的 Cordova:网络项目文件夹的问题 (Windows)
【发布时间】:2019-01-10 09:13:14
【问题描述】:

我有这种情况,我的所有 Cordova 项目都存储在 Windows 机器上。在 Windows 中,我使用的是 Android 平台,这没有问题。

对于 iOS 平台,我在 Mac OSX (High Sierra) 上工作,通过网络共享文件夹访问项目文件夹(在 Windows 中)(我需要避免项目文件/文件夹的重复)。在 Mac 中,我可以浏览访问已安装驱动器 (/Volumes/PROJECTS) 的 Windows 文件,我使用 Windows 上存在的授权用户帐户(“spacorum”,具有管理员权限)连接到该驱动器。

我可以从 Mac 终端创建一个新项目,该项目完美地存储在 Windows 共享文件夹中。然后,进入新创建的项目文件夹后,我尝试添加 ios 平台,这个过程永远不会结束,它什么也没做,“/platforms”下没有创建“ios”文件夹。

这是我运行“cordova platform add ios -d”的输出:

No scripts found for hook "before_platform_add".
No version supplied. Retrieving version from config.xml...
Grabbing pinned version.
Using cordova-fetch for cordova-ios@~4.5.4
saving

我必须取消它,否则它会像这样冻结好几天。 但是 Cordova 工作正常,我检查了它,因为如果我在本地文件夹上执行相同的步骤(存储在 Mac OSX 上,而不是通过网络存储在 Windows 中),该过程将按预期结束:

No scripts found for hook "before_platform_add".
No version supplied. Retrieving version from config.xml...
Grabbing pinned version.
Using cordova-fetch for cordova-ios@~4.5.4
saving
Running command: npm install cordova-ios@~4.5.4 --production --save
Command finished with error code 0: npm install,cordova-ios@~4.5.4,--production,--save
Removing "cordova-" prefix from cordova-ios
Adding ios project...
PlatformApi successfully found for platform ios
Creating Cordova project for the iOS platform:
    Path: platforms/ios
    Package: com.example.hello
    Name: Hello
Copying iOS template project to /Users/spacorum/Desktop/test projects/Hello/platforms/ios
iOS project created with cordova-ios@4.5.5
Checking for any plugins added to the project that have not been installed in ios platform
No differences found between plugins added to project and installed in ios platform. Continuing...
PlatformApi successfully found for platform ios
Generating platform-specific config.xml from defaults for iOS at /Users/spacorum/Desktop/test projects/Hello/platforms/ios/Hello/config.xml
Merging project's config.xml into platform-specific iOS config.xml
Merging and updating files from [www, platforms/ios/platform_www] to platforms/ios/www
  mkdir platforms/ios/www/cordova-js-src
  copy  platforms/ios/platform_www/cordova-js-src/exec.js platforms/ios/www/cordova-js-src/exec.js (new file)
  copy  platforms/ios/platform_www/cordova-js-src/platform.js platforms/ios/www/cordova-js-src/platform.js (new file)
  mkdir platforms/ios/www/cordova-js-src/plugin
  mkdir platforms/ios/www/cordova-js-src/plugin/ios
  copy  platforms/ios/platform_www/cordova-js-src/plugin/ios/console.js platforms/ios/www/cordova-js-src/plugin/ios/console.js (new file)
  copy  platforms/ios/platform_www/cordova-js-src/plugin/ios/logger.js platforms/ios/www/cordova-js-src/plugin/ios/logger.js (new file)
  copy  platforms/ios/platform_www/cordova.js platforms/ios/www/cordova.js (updated file)
  copy  www/index.html platforms/ios/www/index.html (updated file)
  copy  www/js/index.js platforms/ios/www/js/index.js (updated file)
Current launch storyboard undefined
Not changing launch storyboard setting in info plist.
Wrote out iOS Bundle Identifier "com.example.hello" and iOS Bundle Version "1.0.0" to /Users/spacorum/Desktop/test projects/Hello/platforms/ios/Hello/Hello-Info.plist
No need to update build settings for launch storyboard support.
iOS Product Name has not changed (still "Hello")
This app does not have icons defined
This app does not have splash screens defined
Updating launch storyboard images at platforms/ios/Hello/Images.xcassets/LaunchStoryboard.imageset/
Updating Storyboard image set contents.json
This app does not have additional resource files defined
Prepared iOS project successfully
Installing plugin "cordova-plugin-whitelist" following successful platform add of ios
Found variables for "cordova-plugin-whitelist". Processing as cli_variables.
Installing "cordova-plugin-whitelist" for ios
Running command: "/Users/spacorum/Desktop/test projects/Hello/platforms/ios/cordova/version" 
Command finished with error code 0: /Users/spacorum/Desktop/test projects/Hello/platforms/ios/cordova/version 
Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-whitelist on ios platform only.
No scripts found for hook "before_plugin_install".
Install start for "cordova-plugin-whitelist" on ios.
Beginning processing of action stack for ios project...
Action stack processing complete.
Install complete for cordova-plugin-whitelist on ios.
Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-whitelist on ios platform only.
No scripts found for hook "after_plugin_install".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in ios platform
No differences found between plugins added to project and installed in ios platform. Continuing...
Generating platform-specific config.xml from defaults for iOS at /Users/spacorum/Desktop/test projects/Hello/platforms/ios/Hello/config.xml
Merging project's config.xml into platform-specific iOS config.xml
Merging and updating files from [www, platforms/ios/platform_www] to platforms/ios/www
  copy  platforms/ios/platform_www/cordova_plugins.js platforms/ios/www/cordova_plugins.js (updated file)
Current launch storyboard undefined
Not changing launch storyboard setting in info plist.
Wrote out iOS Bundle Identifier "com.example.hello" and iOS Bundle Version "1.0.0" to /Users/spacorum/Desktop/test projects/Hello/platforms/ios/Hello/Hello-Info.plist
No need to update build settings for launch storyboard support.
iOS Product Name has not changed (still "Hello")
This app does not have icons defined
This app does not have splash screens defined
Updating launch storyboard images at platforms/ios/Hello/Images.xcassets/LaunchStoryboard.imageset/
Updating Storyboard image set contents.json
This app does not have additional resource files defined
Prepared iOS project successfully
No scripts found for hook "after_prepare".
Saving ios@4.5.5 into platforms.json
--save flag or autosave detected
Saving ios@~4.5.5 into config.xml file ...
adding ios to cordova.platforms array in package.json
No scripts found for hook "after_platform_add".

如果这是权限问题,我不知道如何解决。 Windows 共享文件夹具有完全访问权限,我以授权用户身份登录。另外,我能够创建项目,如果我没有 Mac 的权限,我怀疑我可以做到,对吧?

注意:我注意到,如果我在 Mac 终端 (ls -la) 上列出从 Windows 共享的文件夹,每个文件夹的默认权限都为“700”,我无法使用 chmod 更改它,没有任何变化。另一方面,我在 Mac 上的本地项目文件夹中的每个子文件夹都具有更多权限 (755),我可以使用 chmod 毫无问题地更改它。

不是一个重度 *nix 用户,所以任何帮助都将不胜感激,我已经在这里呆了一个星期了。

【问题讨论】:

    标签: ios macos cordova networking directory


    【解决方案1】:

    启动命令时似乎出现了问题:

    npm install cordova-ios@~4.5.4 --production --save
    

    在 Mac OSX 上从 Cordova 工作区(位于 Windows 共享文件夹中)使用调试标志启动它时的输出是这样的:

    npm info it worked if it ends with ok
    npm info using npm@6.3.0
    npm info using node@v10.7.0
    npm http fetch GET 304 https://registry.npmjs.org/cordova-ios 361ms (from cache)
    npm timing stage:loadCurrentTree Completed in 3628ms
    npm timing stage:loadIdealTree:cloneCurrentTree Completed in 4ms
    npm timing stage:loadIdealTree:loadShrinkwrap Completed in 22ms
    npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 3624ms
    npm timing stage:loadIdealTree Completed in 3720ms
    npm timing stage:generateActionsToTake Completed in 572ms
    npm timing audit compress Completed in 13ms
    npm info audit Submitting payload of 1190bytes
    npm timing audit submit Completed in 1095ms
    npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1092ms
    npm timing audit body Completed in 2ms
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/package.json'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.eslintignore'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.eslintrc.yml'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.gitattributes'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.istanbul.yml'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.ratignore'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/.travis.yml'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/appveyor.yml'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/component.json'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/CONTRIBUTING.md'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/LICENSE'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/NOTICE'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/README.md'
    WARN tar EIO: i/o error, open '/Volumes/PROJECTS/Hello/node_modules/.staging/cordova-ios-5086fba7/RELEASENOTES.md'
    ⸨       ░░░░░░░░░░░⸩ ⠹ extract:cordova-ios: timing audit body Completed in 2ms
    

    相反,在位于 Mac OSX 的本地工作区上运行时的输出很好:

    npm info it worked if it ends with ok
    npm info using npm@6.3.0
    npm info using node@v10.7.0
    npm http fetch GET 200 https://registry.npmjs.org/cordova-ios 75ms (from cache)
    npm timing stage:loadCurrentTree Completed in 2096ms
    npm timing stage:loadIdealTree:cloneCurrentTree Completed in 3ms
    npm timing stage:loadIdealTree:loadShrinkwrap Completed in 259ms
    npm http fetch GET 304 https://registry.npmjs.org/pegjs 1121ms (from cache)
    npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 5389ms
    npm timing stage:loadIdealTree Completed in 5740ms
    npm timing stage:generateActionsToTake Completed in 47ms
    npm timing audit compress Completed in 11ms
    npm info audit Submitting payload of 1244bytes
    npm timing audit submit Completed in 1115ms
    npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1114ms
    npm timing audit body Completed in 2ms
    npm timing action:extract Completed in 4074ms
    npm info lifecycle cordova-ios@4.5.5~preuninstall: cordova-ios@4.5.5
    npm info lifecycle cordova-ios@4.5.5~uninstall: cordova-ios@4.5.5
    npm info lifecycle cordova-ios@4.5.5~postuninstall: cordova-ios@4.5.5
    npm timing action:unbuild Completed in 22ms
    npm timing action:remove Completed in 328ms
    npm timing action:finalize Completed in 43ms
    npm timing action:refresh-package-json Completed in 36ms
    npm info lifecycle cordova-ios@4.5.5~preinstall: cordova-ios@4.5.5
    npm timing action:preinstall Completed in 2ms
    npm info linkStuff cordova-ios@4.5.5
    npm timing action:build Completed in 8ms
    npm info lifecycle cordova-ios@4.5.5~install: cordova-ios@4.5.5
    npm timing action:install Completed in 3ms
    npm info lifecycle cordova-ios@4.5.5~postinstall: cordova-ios@4.5.5
    npm timing action:postinstall Completed in 3ms
    npm timing stage:executeActions Completed in 5001ms
    npm timing stage:rollbackFailedOptional Completed in 1ms
    npm timing stage:runTopLevelLifecycles Completed in 12979ms
    npm info lifecycle undefined~preshrinkwrap: undefined
    npm info lifecycle undefined~shrinkwrap: undefined
    npm info lifecycle undefined~postshrinkwrap: undefined
    npm WARN com.example.hello@1.0.0 No repository field.
    
    + cordova-ios@4.5.5
    updated 1 package and audited 128 packages in 13.272s
    found 0 vulnerabilities
    
    npm timing npm Completed in 14794ms
    npm info ok
    

    至少我可以排除网络问题,npm 和 cordova 也可以正常工作。这似乎是 Windows 端的权限问题,在项目“/node_modules/.staging/”子文件夹中。我看不出如何,因为父文件夹“/PROJECTS”下的每个子文件夹对所有人(管理员、登录用户和任何其他用户)都是可写的。

    我试图在 Windows 中关闭“node_modules”子文件夹中的只读标志,但是一旦我重新打开对话窗口,它又会被启用。

    我也试过关闭 Windows 10 防火墙和 Defender,没有任何区别。


    更新和修复:最后,一个解决方案。我在这里分享这个,以防有人遇到相同的情况和问题。我在“/Users/myusername/.npm-cache/_logs/”下找到了一个日志,它为我指明了正确的方向:

    Error: Unknown system error -102: Unknown system error -102, symlink '../nopt/bin/nopt.js' -> '/Volumes/PROJECTS/Hello/node_modules/cordova-ios/node_modules/ios-sim/node_modules/.bin/nopt'
    

    我读到这可能与 OSX 系统在 npm 命令启动期间无法创建符号链接(在 WINDOWS 中)有关。我在运行 npm 命令时使用它来避免符号链接:

    npm config set bin-links false
    

    这就成功了。现在iOS平台已经从OSX终端完美添加,使用远程存储在WINDOWS机器中的项目文件夹。

    案件解决了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      • 2020-12-23
      • 2012-08-26
      • 2017-04-08
      • 2016-01-31
      • 2014-08-20
      相关资源
      最近更新 更多