Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Can't resolve '@master.technology/permissions' in version 1.3.12 #49

Open
tylerablake opened this issue Nov 2, 2021 · 31 comments
Open

Comments

@tylerablake
Copy link

After cleaning and rebuilding my mobile app I'm getting the following error:

ERROR in ../node_modules/nativescript-permissions/permissions.js
Module not found: Error: Can't resolve '@master.technology/permissions' in '/mobile-app/booking/node_modules/nativescript-permissions'
 @ ../node_modules/nativescript-permissions/permissions.js 13:17-58
 @ ../node_modules/@nativescript/geolocation/index.js
 @ ./modules/club/components/search/search.component.ts
 @ ./modules/scores/pages/form/form.component.ts
 @ ./modules/scores/pages/index.ts
 @ ./modules/scores/scores.module.ts
 @ ./routing/app.routing.ts
 @ ./app.module.ts
 @ ./main.ts
Executing webpack failed with exit code 2.

Let me know if there are any other details I can provide to help resolve this, thanks!

@NathanaelA
Copy link
Owner

Can you tell me:

  1. NativeScript version (ns --version)
  2. What version of typescript you are using.
  3. What version of node & npm you are using.
  4. If there is a @master.technology/permissions folder in either the root node_modules/ or in node_modules/nativescript-permissions/node_modules

@tylerablake
Copy link
Author

Yeah no problem!

  1. NativeScript version (ns --version)

8.0.1

  1. What version of typescript you are using.

3.9.7

  1. What version of node & npm you are using.

node - v11.3.0
npm - 6.4.1

  1. If there is a @master.technology/permissions folder in either the root node_modules/ or in node_modules/nativescript-permissions/node_modules

There is a @master.technology/permissions folder in the root but not inside of the nativescript/permissions folder

Let me know if you need anything else!

@NathanaelA
Copy link
Owner

Node 11 is actually pretty old, that might be the cause. But one thing that might fix the issue on your machine without upgrading node is just copying the @master.technology folder from the root node_modules into the nativescript_permissions/node_modules.

@alexziskind1
Copy link

alexziskind1 commented Nov 3, 2021

Can confirm this is happening here as well. Looks like with the latest change this repo now points to another repo, but perhaps doesn't export from package.json ?

Node 14 here

@NathanaelA
Copy link
Owner

It does now point to another npm module (@master.technology/permissions) When I first started all my plugins NPM didn't have any name spaces. Now as I update plugins I've been moving them into my own name space. However to keep from breaking everybody I release a shim package that redirects to the new name.

I've done this many times over the years. In fact that is how Plugins -> NS-Permssions works, one plugin refers to the other. And how all my "sub-plugins" of NS-Sqlite work.

I'm at a loss as to why it isn't working for several of you. It is working for the vast majority of people (close to 600 downloads of this version already), otherwise the number of issues would be crazy high.

At the moment, everything "here" is working perfectly on both iOS and Android. I even manually made my demo app go to the latest npm version of ns-permissions (rather than its final location of @master.technology/permissions) just to verify that the chaining would work and it is working for me.

Interim solutions:

  1. You can for sure fix this by updating all references to use @master.technology/permissions instead of the old nativescript-permissions name.
  2. You can update your webpack rules to rewrite (nativescript-permissions to @master.technology/permissions)
  3. You can also use a older version of nativescript-permissions (pre @master.technology/permissions branch) but then you lose the shared ios & android permission ability as the new version of permissions supports getting permissions on both platforms now.

I would like to know a couple things:

  1. What version of Node & NPM
  2. What version of NativeScript CLI you are using (tns --version)
  3. Your apps package.json file.

@Swamp3
Copy link

Swamp3 commented Nov 4, 2021

Experiencing the same issue.
Stripped 3. to only contain nativescript modules.

  1. 14
  2. 6.8.0
    "@nstudio/nativescript-checkbox": "1.0.0",
    "@nstudio/nativescript-pulltorefresh": "^1.0.1",
    "nativescript": "6.8.0",
    "nativescript-angular": "^8.0.2",
    "nativescript-email": "^1.6.0",
    "nativescript-image": "^2.2.5",
    "nativescript-imagepicker": "^7.1.0",
    "nativescript-pdf-view": "^2.2.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toasty": "^2.0.1",
    "nativescript-ui-listview": "^8.2.0",
    "tns-core-modules": "^6.5.20",

@NathanaelA
Copy link
Owner

@Swamp3 , @alexziskind1 , @tylerablake - are any of you by any chance using the NS/Angular code sharing Schematics?

@tylerablake
Copy link
Author

I'm using NS + Angular but not code sharing schematics

@Swamp3
Copy link

Swamp3 commented Nov 5, 2021

@NathanaelA if you are talking about the following code block, then yes. We are also sharing code for a web and the nativescript apps. (.ts and .tns.ts files etc.)

  "cli": {
    "defaultCollection": "@nativescript/schematics"
  },

@NathanaelA
Copy link
Owner

@Swamp3 - Yep, that probably means that everything was setup by NS schematics, even if you aren't using it for code sharing. Not 100% sure, but it does seem like everyone so far effected there project was setup using the @ns/schematics or perhaps it is just angular users in general??? (@alexziskind1 - how was your project set up?). The reason I suspected schematics (or even maybe xplat???) is that they have custom resolving for typescript and perhaps this is the reason it isn't working is because it doesn't search proper node_modules folder.

A couple things you can try:

  1. Copy the @master.technology/permissions into the nativescript-permissions/node_modules folder (create the node_modules folder in there if if it doesn't already exist).
  2. Copy the @master.technology/permissions into the very root node_modules folder which I believe is all the way at the base of the schemetics setup.

If either of those works, then it is probably a resolving rule of the tsconfig file needs to be fixed.

@RomainTex
Copy link

Hi, i have the same issue as above.
I'm using code sharing too.

  1. node : 12.19 + npm 6.4.18
  2. 8.1.3 (tried in 6.5 too) we are using a NS 6 project.
  3. "@angular/animations": "8.0.0",
    "@angular/common": "8.0.0",
    "@angular/compiler": "8.0.0",
    "@angular/core": "8.0.0",
    "@angular/forms": "8.0.0",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "8.0.0",
    "@angular/platform-browser-dynamic": "8.0.0",
    "@angular/router": "8.0.0",
    "@master.technology/permissions": "^2.0.1",
    "@nativescript/appversion": "^2.0.0",
    "@nstudio/nativescript-floatingactionbutton": "^1.0.1",
    "@types/mathjs": "^6.0.5",
    "core-js": "^2.5.4",
    "crypto-js": "^3.1.9-1",
    "mathjs": "^7.1.0",
    "moment": "^2.23.0",
    "nativescript": "^6.1.0",
    "nativescript-angular": "8.0.2",
    "nativescript-camera": "^4.1.1",
    "nativescript-drop-down": "^4.0.1",
    "nativescript-feedback": "^1.3.11",
    "nativescript-image-swipe": "^5.0.1",
    "nativescript-imagepicker": "^6.3.0",
    "nativescript-localize": "^4.2.0",
    "nativescript-multi-select": "^1.0.6",
    "nativescript-sqlite": "^2.3.3",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-gauge": "5.0.0",
    "nativescript-ui-listview": "7.0.0",
    "nativescript-ui-sidedrawer": "7.0.0",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^6.5.3",
    "tns-android": "^6.1.0",
    "tns-core-modules": "^6.1.0",
    "typeorm": "0.2.13",
    "zone.js": "0.9.1"

I already have @master.technology/permissions in the correct location (where you advise to past the module), i still have the same error as others.

@NathanaelA
Copy link
Owner

@RomainTex -

  1. Can you verify that you have a copy of the @master.technology/permissions in the app/node_modules/nativescript-permissions/node_modules/[HERE]
  2. Was this project setup using xplat or angular schematics?

For everyone else we are already at about 1,200 downloads a week on this version:

  • Does anyone have a non-angular project that this is occurring on?
  • Anyone have a non-xplat or non-schematic Angular setup? Just a project setup via tns create myproject --ng that duplicates this issue.
  • Figuring out the thing that is different in your setup from the vast majority of people is what we need to figure out...

@RomainTex
Copy link

Thank you for you quick answer @NathanaelA

  1. I can confirm you that the package is present (I tried this in two environments: Linux and Mac:both have the error since one week for android build) but it did not fix the problem.
  2. I think we used tns to create our project. I am not sure what you mean by a setup using angular schematics.

I will try to reproduce the error in a new project. I keep you posted if i succeed in reproducing the behaviour.

@asixela
Copy link

asixela commented Nov 10, 2021

@NathanaelA
I found this on stack overflow: https://stackoverflow.com/questions/69841570/error-in-nativescript-permissions-when-running-android-app.
Maybe it can help to find the problem.

@RomainTex
Copy link

@NathanaelA
I did succeed in reproducing the error in a new project.
With:

  • nativescript-cli: 6.5.1
  • node 10.21 and npm 6.14.4

Steps to reproduce:

  1. tns create --ng titi
  2. tns plugin add nativescript-imagepicker
  3. Modify the app.component.ts to use the lib, something like that:
import { Component } from "@angular/core";
import { ImageSource } from "tns-core-modules";
import * as imagepicker from "nativescript-imagepicker";


@Component({
    selector: "ns-app",
    templateUrl: "./app.component.html"
})
export class AppComponent { 

    public async selectPicture(): Promise<ImageSource> {
        let newPicture: ImageSource;
        const context = imagepicker.create({
            mode: "multiple"
        });

        await context.authorize().then(
            async () => {
            await context.present().then(
                (selection) => {
                selection.forEach(async (imageAsset) => {
                    const image = new ImageSource();
                    await image.fromAsset(imageAsset).then(source => {
                    newPicture = source;
                    });
                });
                }
            );
            },
            () =>
                console.log("error")
        );

    return newPicture;
  }
}
  1. Run: tns run android

And you should have the following error:

ERROR in ../node_modules/nativescript-permissions/permissions.js
Module not found: Error: Can't resolve '@master.technology/permissions' in '/media/romain/storage/work/poc/titi/node_modules/nativescript-permissions'
@ ../node_modules/nativescript-permissions/permissions.js 13:17-58
@ ../node_modules/nativescript-imagepicker/imagepicker.js
@ ./app/app.component.ts
@ ./app/app.module.ts
@ ./main.ts

@zuhairmhtb
Copy link

zuhairmhtb commented Nov 13, 2021

Migrating from NativeScript 7 to NativeScript 8 fixed the issue for me. To migrate see the link https://v6.docs.nativescript.org/angular/releases/upgrade-instructions

$ tns migrate

After migration, when running the app it might say thar zone.js not found. For that the fix is available at:
manfredsteyer/ngx-build-plus#4
Add
import 'zone.js' in main.ts

However, a lot of libraries i.e. Apollo is not adaptable with NativeScript 8. Is there any way to make this library compatible with NativeScript 7?

@manojkumawat003
Copy link

manojkumawat003 commented Nov 24, 2021

if you still did not get the issue resolved then follow these instructions -

  1. go to nativescript-permissions in node_modules
  2. rename or delete permission.js file
  3. now go to @master.technology/permission folder
  4. copy permissions.android.js and permissions.ios.js file
  5. paste these files to nativescript-permissions folder
    6
    Capture
    .

@RomainTex
Copy link

Thanks a lot for your precious help @manojkumawat003 !!! It worked for us, you allowed us to make app releases again 👍 🥇

@manojkumawat003
Copy link

Thanks a lot for your precious help @manojkumawat003 !!! It worked for us, you allowed us to make app releases again 👍 🥇

its my pleasure.!!

@sureshpodeti
Copy link

@manojkumawat003 , Your trick worked!. Thanks.

@nidheeshfullstack
Copy link

if you still did not get the issue resolved then follow these instructions, it helped me-

  1. go to nativescript-permissions in node_modules
  2. rename or delete permission.js file
  3. now go to @master.technology/permission folder
  4. copy permissions.android.js and permissions.ios.js file
  5. paste these files to nativescript-permissions folder
    6
    Capture
    .

I did not have any @master.technology/nativescript folder

@vamsiitengineer
Copy link

if you still did not get the issue resolved then follow these instructions, it helped me-

  1. go to nativescript-permissions in node_modules
  2. rename or delete permission.js file
  3. now go to @master.technology/permission folder
  4. copy permissions.android.js and permissions.ios.js file
  5. paste these files to nativescript-permissions folder
    6
    Capture
    .

This worked for me, thank you for posting

@nidheeshfullstack
Copy link

This process worked for me, Thanks a lot.

@nidheeshfullstack
Copy link

if you still did not get the issue resolved then follow these instructions -

  1. go to nativescript-permissions in node_modules
  2. rename or delete permission.js file
  3. now go to @master.technology/permission folder
  4. copy permissions.android.js and permissions.ios.js file
  5. paste these files to nativescript-permissions folder
    6
    Capture
    .

After do this process i have faced this issue.

image

@nidheeshfullstack
Copy link

What can i do for that
@manojkumawat003 can you suggest anything

@selvanathan123
Copy link

if you still did not get the issue resolved then follow these instructions -

  1. go to nativescript-permissions in node_modules
  2. rename or delete permission.js file
  3. now go to @master.technology/permission folder
  4. copy permissions.android.js and permissions.ios.js file
  5. paste these files to nativescript-permissions folder
    6
    Capture
    .

After do this process i have faced this issue.

image

I am also faced this same issue
@nidheeshfullstack @manojkumawat003 @alexziskind1

@DanLatimer
Copy link

Manually editing dependencies downloaded into the node_modules folder isn't a great solution. It's not going to work with my CI/CD workflow :( I'm going to keep looking for a work around

@NathanaelA
Copy link
Owner

Can someone upload a test project that exhibits this behavior, my tests all work fine so I'm at a loss as to why it is having issues for some of you.

@selvanathan123
Copy link

selvanathan123 commented May 11, 2022 via email

@DanLatimer
Copy link

DanLatimer commented May 11, 2022

@NathanaelA here's a repo that reproduces the error, just check out the repo, you can use the latest nativescript cli (currently 8.2.3) and run ns debug android

https://github.com/DanLatimer/nativescript-permissions-error

To create this repo I downgraded my nativescript cli to 6.5.1 then created a 6.5.1 application, then followed the instructions here, then upgraded my nativescript cli back to latest and tried to run the app

@DanLatimer
Copy link

DanLatimer commented May 11, 2022

It looks like the nativescript-permissions repo contains a single file that require's @master.technology/permissions and exports that. But inside that repo we have an ios and an android file.

I was curious what would happen if we had a .android.js and a .ios.js file in the nativescript-permissions package that both require/export their respective files. It seems to have produced a working build in the test app. I'm going to test it on my production app so that I can see if the permissions functionality is working or if it's just not failing to compile

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

No branches or pull requests