Skip to content
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

Try to add a static library by using plugin in nativescript Could not install from node_modules/nativescript-plugin as it does not contain a package.json file #3035

Closed
priyangamani opened this issue Aug 4, 2017 · 6 comments

Comments

@priyangamani
Copy link

Dear friend, we, the rest of the NativeScript community really
appreciate your feedback! While we are doing all we can to take care of every
issue, sometimes we get overwhelmed. Because of that, we will consider issues
that are not constructive or problems that cannot be reproduced "dead".
Additionally, we will treat feature requests or bug reports with unanswered
questions regarding the behavior/reproduction for more than 20 days "dead". All
"dead" issues will get closed.

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

iOS/Android/Both

Please provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the
    package.json file of your project)
  • Plugin(s): (look for the version number in the package.json file of your
    project)

Please tell us how to recreate the issue in as much detail as possible.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 4, 2017

@priyangamani please follow the issue template when report issues.

We would like to know:

  • More detailed description of the problem you encounter
  • Steps to reproduce the issue
  • nativescript, node, npm versions
  • package.json of your project
  • What you mean with using plugin in nativescript Could? Is it cloud builds with NativeScript Sidekick?

@priyangamani
Copy link
Author

priyangamani commented Aug 4, 2017

@dtopuzov (Try to add a static library for ios)

node version:v8.2.1
npm version:5.3.0

Plugin structure For Ios:-(By using a static libraries)
I created a plugin structure as below:
├── package.json
└── platforms
└── ios
├──payment
│ └──payment
│ ├──payment.h
└──payment.a

And in package.json:

{
    "name" : "nativescript-payment",
    "version": "0.0.1",
    "nativescript": {
        "platforms": {
            "ios": "1.3.0"
        }
    }
}

After that i tried to add plugin by using this command
tns plugin add ../nativescript-payment

But i failed to add plugin..
Terminal Error Report
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../nativescript-payment" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/macadmin/.npm/_logs/2017-08-04T07_30_57_332Z-debug.log
Command npm install ../nativescript-payment --save failed with exit code 1

plugin add

┌─────────┬───────────────────────────┐
│ Usage │ Synopsis │
│ General │ $ tns plugin add │
└─────────┴───────────────────────────┘

Installs the specified plugin and any packages that it depends on.

Attributes

* <Plugin> is a valid NativeScript plugin, specified by any of the following.
    * A <Name> or <Name>@<Version> where <Name> is the name of a plugin that is published in the npm registry and <Version> is a valid version of this plugin.
    * A <Local Path> to the directory which contains the plugin, including its package.json file.
    * A <Local Path> to a .tar.gz archive containing a directory with the plugin and its package.json file.
    * A <URL> which resolves to a .tar.gz archive containing a directory with the plugin and its package.json file.
    * A <git Remote URL> which resolves to a .tar.gz archive containing a directory with the plugin and its package.json file.

npm ERR! /Users/macadmin/.npm/_logs/2017-08-04T07_30_57_332Z-debug.log

NPM DEBUG LOG:-
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '../nativescript-payment',
1 verbose cli '--save' ]
2 info using npm@3.3.12
3 info using node@v5.5.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData ../nativescript-payment
8 silly fetchOtherPackageData ../nativescript-payment
9 silly cache add args [ '../nativescript-payment, null ]
10 verbose cache add spec ../nativescript-payment
11 silly cache add parsed spec Result {
11 silly cache add raw: '../nativescript-payment,
11 silly cache add scope: null,
11 silly cache add name: null,
11 silly cache add rawSpec: '../nativescript-payment',
11 silly cache add spec: '/Users/macadmin/nativescript-payment,
11 silly cache add type: 'local' }
12 error addLocal Could not install /Users/macadmin/nativescript-payment
13 silly fetchPackageMetaData Error: ENOENT: no such file or directory, open '/Users/macadmin/nativescript-payment'
13 silly fetchPackageMetaData at Error (native)
13 silly fetchPackageMetaData error for ../nativescript-payment{ [Error: ENOENT: no such file or directory, open '/Users/macadmin/nativescript-payment']
13 silly fetchPackageMetaData errno: -2,
13 silly fetchPackageMetaData code: 'ENOENT',
13 silly fetchPackageMetaData syscall: 'open',
13 silly fetchPackageMetaData path: '/Users/macadmin/nativescript-payment' }
14 silly rollbackFailedOptional Starting
15 silly rollbackFailedOptional Finishing
16 silly runTopLevelLifecycles Starting
17 silly runTopLevelLifecycles Finishing
18 silly install printInstalled
19 verbose stack Error: ENOENT: no such file or directory, open '/Users/macadmin/
nativescript-payment'
19 verbose stack at Error (native)
20 verbose cwd /Users/macadmin/HelloWorld
21 error Darwin 16.6.0
22 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "../nativescript-payment" "--save"
23 error node v5.5.0
24 error npm v3.3.12
25 error path /Users/macadmin/nativescript-payment
26 error code ENOENT
27 error errno -2
28 error syscall open
29 error enoent ENOENT: no such file or directory, open '/Users/macadmin/nativescript-payment'
29 error enoent This is most likely not a problem with npm itself
29 error enoent and is related to npm not being able to find a file.
30 verbose exit [ -2, true ]

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 4, 2017

Hi @priyangamani

Unfortunately with npm5 you can not add references to folders in your package.json.
Here is the issue: #3028

The options are:

  • Downgrade to npm4: npm i -g npm@4
  • npm pack your plugin and reference it as local tgz file

Can you please try one of them and let us know if you still experience the issue?

@priyangamani
Copy link
Author

priyangamani commented Aug 4, 2017 via email

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 4, 2017

In this case CLI says:

*Support for Node.js ^4.0.0 is deprecated and will be removed in the next
release of NativeScript. Please, upgrade to the latest Node.js LTS
version. *

So I suggest installing node6 and npm4:

<remove your old versions of nodejs>
brew update
brew install node@6
npm -i -g npm@4

What tns plugin add ../nativescript-eghlpayment will do is:

npm i ../nativescript-eghlpayment --save

So you need npm version that supports this scenario.
Installing the plugin with npm command is good way to verify if the problem is in npm and plugin you have or it is in tns.

@dtopuzov
Copy link
Contributor

Hi @priyangamani npm5 is already supported in nativescript@3.1.3.

Note that npm5 behavour when npm install <folder> is much different compared to npm4 and it is not under our control, so you still may encounter some issues in this case (for example this one).

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

No branches or pull requests

2 participants