TodoApp icon indicating copy to clipboard operation
TodoApp copied to clipboard

Unable to resolve error [ERR_PACKAGE_PATH_NOT_EXPORTED]: pls help

Open Er-sumit opened this issue 4 years ago • 5 comments

While added users.js ended up in error.

⚠   Your requested "node" version "14" doesn't match your global version "16"
i  functions: Watching "/Users/sumit/Desktop/src/firebase/functions" for Cloud Functions...
⚠  functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
⚠  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/sumit/Desktop/src/firebase/node_modules/firebase/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:413:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:652:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/Users/sumit/Desktop/src/firebase/functions/APIs/users.js:6:18)
⚠  We were unable to load your functions code. (see above)

I'm following code from https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/

Pls help!

Er-sumit avatar Sep 07 '21 06:09 Er-sumit

Please check your firebase version to see whether you are using Firebase v9, the new version has some syntax breaking change than v8. This may caused the package not exported issue.

$ firebase --version

I guess this tutorial use firebase v8, you can install this version by following command:

$ npm install -g [email protected]
$ npm i [email protected]

Or if you prefer to use firebase v9, please refer the breaking changes below and change the tutorial code on your own.

  • https://firebase.google.com/docs/web/modular-upgrade
  • https://firebase.google.com/support/release-notes/js#version_800_-_october_26_2020

luoxufeiyan avatar Nov 13 '21 01:11 luoxufeiyan

Please check your firebase version to see whether you are using Firebase v9, the new version has some syntax breaking change than v8. This may caused the package not exported issue.

$ firebase --version

I guess this tutorial use firebase v8, you can install this version by following command:

$ npm install -g [email protected]
$ npm i [email protected]

Or if you prefer to use firebase v9, please refer the breaking changes below and change the tutorial code on your own.

  • https://firebase.google.com/docs/web/modular-upgrade
  • https://firebase.google.com/support/release-notes/js#version_800_-_october_26_2020

hi, I did what you said and installed firebase 8.2.3 and firebase-tool 8.20 and now I get another error:

TypeError: Cannot read property 'INTERNAL' of undefined at Ke (C:\Users\elnatan_nitzan\Desktop\react\todos-app-firebase\node_modules@firebase\auth\dist\auth.js:125:129) at new Ze (C:\Users\elnatan_nitzan\Desktop\react\todos-app-firebase\node_modules@firebase\auth\dist\auth.js:131:288) at C:\Users\elnatan_nitzan\Desktop\react\todos-app-firebase\node_modules@firebase\auth\dist\auth.js:237:277 at Object. (C:\Users\elnatan_nitzan\Desktop\react\todos-app-firebase\node_modules@firebase\auth\dist\auth.js:433:462) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:94:18) ! We were unable to load your functions code. (see above)

elnatanitzan avatar Nov 18 '21 08:11 elnatanitzan

Hi @elnatanitzan,

What's your firebase-admin package version? I'm using 8.10.0 and it works for me.

luoxufeiyan avatar Nov 19 '21 08:11 luoxufeiyan

@luoxufeiyan

Finally after twice I did uinstall and reinstall for versions 8.2, and then npm update Everything works fine for me. Thanks

elnatanitzan avatar Nov 19 '21 10:11 elnatanitzan

you can use

const firebase = require('firebase/compat/app');

to use newer versions of firebase and being compatible with old ones too :)

Also having imported:

require('firebase/compat/auth')

you must replace all lines where you use:

firebase.auth()...

for

const auth = firebase.auth()

in order to have something like this:

auth.signInWithEmailAndPassword(user.email, user.password) ...

jcardenaslie avatar Jun 03 '22 03:06 jcardenaslie