-
-
Notifications
You must be signed in to change notification settings - Fork 194
Description
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
npm i -g pnpm
.pnpm i -g nativescript
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:
pnpm i -g yargs-parser
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