You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/02 19:24:07 UTC
[GitHub] janpio edited a comment on issue #159: mobile-spec project creation
fails with error "Cannot find module 'cordova-common'"
janpio edited a comment on issue #159: mobile-spec project creation fails with error "Cannot find module 'cordova-common'"
URL: https://github.com/apache/cordova-mobile-spec/issues/159#issuecomment-443534426
Investigation where the error is coming from:
1. Recreate the problem manually:
```
C:\Projects\cordova5
λ C:\Projects\cordova5\cordova-cli\bin\cordova create mobilespec_ios_manual org.apache.cordova.mobilespec MobileSpec_Tests --template cordova-mobile-spec\www
Warning: using prerelease version 8.0.1-dev (cordova-lib@9.0.0-dev)
Creating a new cordova project.
C:\Projects\cordova5
λ cd mobilespec_ios_manual
C:\Projects\cordova5\mobilespec_ios_manual
λ C:\Projects\cordova5\cordova-cli\bin\cordova platform add "C:\Projects\cordova5\cordova-ios" --verbose
Warning: using prerelease version 8.0.1-dev (cordova-lib@9.0.0-dev)
No scripts found for hook "before_platform_add".
fetch: Installing C:\Projects\cordova5\cordova-ios to C:\Projects\cordova5\mobilespec_ios_manual
Running command: npm install C:\Projects\cordova5\cordova-ios --production --save
Command finished with error code 0: npm install,C:\Projects\cordova5\cordova-ios,--production,--save
Removing "cordova-" prefix from cordova-ios
Warning: using prerelease platform ios@5.0.0-dev.
Use 'cordova platform add ios@latest' to add the latest published version instead.
Adding ios project...
PlatformApi successfully found for platform ios
Creating Cordova project for the iOS platform:
Path: platforms\ios
Package: org.apache.cordova.mobilespec
Name: MobileSpec_Tests
Copying iOS template project to C:\Projects\cordova5\mobilespec_ios_manual\platforms\ios
iOS project created with cordova-ios@5.0.0-dev
Cannot find module 'unorm'
Error: Cannot find module 'unorm'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Projects\cordova5\mobilespec_ios_manual\platforms\ios\cordova\Api.js:24:13)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
```
2. Last output before error is `iOS project created with cordova-ios@5.0.0-dev`.
Code for this lives at:
https://github.com/apache/cordova-ios/blob/62ebfbd74aff11b9fa0ca26685ee0578ecd9150f/bin/lib/create.js#L255-L262
... which is the last call of `createProject`:
https://github.com/apache/cordova-ios/blob/62ebfbd74aff11b9fa0ca26685ee0578ecd9150f/bin/lib/create.js#L198-L239
... which is called in `createPlatform`:
https://github.com/apache/cordova-ios/blob/2cd93097ec5d5989bc758f15db75011829c84c2b/bin/templates/scripts/cordova/Api.js#L113-L135
3. So we know what happens after that output:
https://github.com/apache/cordova-ios/blob/2cd93097ec5d5989bc758f15db75011829c84c2b/bin/templates/scripts/cordova/Api.js#L124-L129
4. The crashing command seems to be:
```
var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
```
This requires `C:\Projects\cordova5\mobilespec_ios_manual\platforms\ios\cordova\Api.js` in this case (which is the same file being executed, but now inside the installed platform). `unorm` is the first dependency "non-system" dependency in this file.
5. Yep, for `cordova-android` the first require in the file is `cordova-common`: https://github.com/apache/cordova-android/blob/8a4ae311ce165e31f0511ae43274aa52d3773fd2/bin/templates/cordova/Api.js#L24
So now I know why this is crashing: `Api.js` in the platform does not have its dependencies available. Now to find out why.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org