Skip to content

tns init fails, ins init --force produce invalid app #2559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dtopuzov opened this issue Feb 21, 2017 · 4 comments
Closed

tns init fails, ins init --force produce invalid app #2559

dtopuzov opened this issue Feb 21, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@dtopuzov
Copy link
Contributor

Steps to reproduce:
tns init --path MyApp

Output:

 stderr: 
SyntaxError: Unexpected token n in JSON at position 4
    at Object.parse (native)
    at NodePackageManager.<anonymous> (/Users/topuzov/Git/nativescript-cli-tests/node_modules/nativescript/lib/node-package-manager.js:103:25)
    at next (native)
    at fulfilled (/Users/topuzov/Git/nativescript-cli-tests/node_modules/nativescript/lib/node-package-manager.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:103:7)
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }

Notes:
tns init --path MyApp --force creates app, but without App Resources.
I think this command is useless, since no one complained it does not work without --force and it produce not build able app with --force.

@dtopuzov dtopuzov added the bug label Feb 21, 2017
@dtopuzov dtopuzov added this to the 3.0.0 milestone Feb 21, 2017
@rosen-vladimirov rosen-vladimirov self-assigned this Feb 21, 2017
@pkoleva pkoleva removed this from the 3.0.0-RC milestone Feb 24, 2017
@mnaughto
Copy link

FWIW, I tracked this down to here https://github.com/NativeScript/nativescript-cli/blob/master/lib/services/init-service.ts#L109. In other places, the second argument to $npm.view() is a hash like {json: true, versions: true}, whereas here it just passes "versions", so the output of the subsequently invoked npm view command is not valid JSON.

@mnaughto
Copy link

I can open a pull request if that'd be useful, but I'm guessing a normal contributor to this project might have an easier time.

@etabakov etabakov added this to the 3.0.0-RC milestone Mar 20, 2017
@yyosifov
Copy link
Contributor

Hi,

@mnaughto You are right - this was one of the problems. I've set explicitly in the NPM View method to set { json: true } always. Another error was that it seems like the NPM View response has changed as a structure and this alone didn't fix the problem. Now npm view tns-ios versions --json returns an array of versions, not as we expected an object. You can view the pull request opened here: #2625. Thanks a bunch for your effort! Let me know if this fix sounds reasonable to you.

@dtopuzov The init command only creates a package.json definition just like npm init does. The reason why the --force flag was working is that it didn't search through the versions from the NPM but directly uses the latest version available. @rosen-vladimirov can you confirm this is the expected behavior, and not a full app created from a template?

Thanks guys!

@mnaughto
Copy link

@yyosifov #2625 is essentially what I did to get it to run - I didn't bother changing the signature of the $npm.view() function, but that change seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants