Skip to content

Missing yargs-parser dependency #4814

@aparajita

Description

@aparajita

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.4.2
  • Cross-platform modules: 5.4.0
  • Android Runtime: 5.4.0
  • iOS Runtime: 5.4.0

Describe the bug

package.json is missing yargs-parser as a dependency. It is required here. You are getting away with it currently because npm and yarn currently use a flattened package hierarchy, and yargs installs yargs-parser. That's an implementation detail of the package manager that should not be relied on. Smarter package managers like pnpm (and no doubt future versions of npm and yarn) which do not flatten the hierarchy cause tns to break.

To Reproduce

  1. npm i -g pnpm.
  2. pnpm i -g nativescript
  3. tns info

You'll get something like this error output:

Cannot find module 'yargs-parser'
Require stack:
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/lib/options.js
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/lib/common/yok.js
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/lib/common/bootstrap.js
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/lib/bootstrap.js
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/lib/nativescript-cli.js
- /Users/aparajita/.nvm/versions/node/v12.6.0/pnpm-global/2/node_modules/.registry.npmjs.org/nativescript/5.4.2/node_modules/nativescript/bin/tns

Now do this:

  1. pnpm i -g yargs-parser
  2. tns info

No error.

Expected behavior

All packages that are directly required by source code should be declared in package.json. If that is done there will be no missing module error.

Sample project

Additional context

Metadata

Metadata

Assignees

Labels

bugtslintDescribes that we need to add tslint rule to validate the behavior will not happen in the future.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions