INTERNAL/MODULES/cjs/loader.js:456引发e;^错误[ERR_PACKAGE_PATH_NOT_EXPORTED]:未在中定义导出(&Q) [英] internal/modules/cjs/loader.js:456 throw e; ^ Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in
本文介绍了INTERNAL/MODULES/cjs/loader.js:456引发e;^错误[ERR_PACKAGE_PATH_NOT_EXPORTED]:未在中定义导出(&Q)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行后npm start
这是我的结果是...
数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">> nodefirebase_curd@1.0.0 start
> nodemon index.js
[nodemon] 2.0.13
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
internal/modules/cjs/loader.js:456
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:Users ong1Desktop est-Firebase
odeFirebase_CURD
ode_modulesfirebasepackage.json
at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
at packageExportsResolve (internal/modules/esm/resolve.js:508:3)
at resolveExports (internal/modules/cjs/loader.js:450:36)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:Users ong1Desktop est-Firebase
odeFirebase_CURDdb.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
[nodemon] app crashed - waiting for file changes before starting...
我以前从未看到过此错误...
这就是错误提到的文件。 (这是 我的项目中的ode_modesFirebasepackage.json。)
数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">{
"name": "firebase",
"version": "9.1.0",
"description": "Firebase JavaScript library for web and Node.js",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"license": "Apache-2.0",
"homepage": "https://firebase.google.com/",
"keywords": [
"authentication",
"database",
"Firebase",
"firebase",
"realtime",
"storage",
"performance",
"remote-config"
],
"files": [
"**/dist/",
"**/package.json",
"/firebase*.js",
"/firebase*.map",
"compat/index.d.ts"
],
"exports": {
"./analytics": {
"node": {
"require": "./analytics/dist/index.cjs.js",
"import": "./analytics/dist/index.mjs"
},
"default": "./analytics/dist/index.esm.js"
},
"./app": {
"node": {
"require": "./app/dist/index.cjs.js",
"import": "./app/dist/index.mjs"
},
"default": "./app/dist/index.esm.js"
},
"./app-check": {
"node": {
"require": "./app-check/dist/index.cjs.js",
"import": "./app-check/dist/index.mjs"
},
"default": "./app-check/dist/index.esm.js"
},
"./auth": {
"node": {
"require": "./auth/dist/index.cjs.js",
"import": "./auth/dist/index.mjs"
},
"default": "./auth/dist/index.esm.js"
},
"./auth/cordova": {
"node": {
"require": "./auth/cordova/dist/index.cjs.js",
"import": "./auth/cordova/dist/index.mjs"
},
"default": "./auth/cordova/dist/index.esm.js"
},
"./auth/react-native": {
"node": {
"require": "./auth/react-native/dist/index.cjs.js",
"import": "./auth/react-native/dist/index.mjs"
},
"default": "./auth/react-native/dist/index.esm.js"
},
"./database": {
"node": {
"require": "./database/dist/index.cjs.js",
"import": "./database/dist/index.mjs"
},
"default": "./database/dist/index.esm.js"
},
"./firestore": {
"node": {
"require": "./firestore/dist/index.cjs.js",
"import": "./firestore/dist/index.mjs"
},
"default": "./firestore/dist/index.esm.js"
},
"./firestore/lite": {
"node": {
"require": "./firestore/lite/dist/index.cjs.js",
"import": "./firestore/lite/dist/index.mjs"
},
"default": "./firestore/lite/dist/index.esm.js"
},
"./functions": {
"node": {
"require": "./functions/dist/index.cjs.js",
"import": "./functions/dist/index.mjs"
},
"default": "./functions/dist/index.esm.js"
},
"./messaging": {
"node": {
"require": "./messaging/dist/index.cjs.js",
"import": "./messaging/dist/index.mjs"
},
"default": "./messaging/dist/index.esm.js"
},
"./messaging/sw": {
"node": {
"require": "./messaging/sw/dist/index.cjs.js",
"import": "./messaging/sw/dist/index.mjs"
},
"default": "./messaging/sw/dist/index.esm.js"
},
"./performance": {
"node": {
"require": "./performance/dist/index.cjs.js",
"import": "./performance/dist/index.mjs"
},
"default": "./performance/dist/index.esm.js"
},
"./remote-config": {
"node": {
"require": "./remote-config/dist/index.cjs.js",
"import": "./remote-config/dist/index.mjs"
},
"default": "./remote-config/dist/index.esm.js"
},
"./storage": {
"node": {
"require": "./storage/dist/index.cjs.js",
"import": "./storage/dist/index.mjs"
},
"default": "./storage/dist/index.esm.js"
},
"./compat/analytics": {
"node": {
"require": "./compat/analytics/dist/index.cjs.js",
"import": "./compat/analytics/dist/index.mjs"
},
"default": "./compat/analytics/dist/index.esm.js"
},
"./compat/app": {
"node": {
"require": "./compat/app/dist/index.cjs.js",
"import": "./compat/app/dist/index.mjs"
},
"default": "./compat/app/dist/index.esm.js"
},
"./compat/app-check": {
"node": {
"require": "./compat/app-check/dist/index.cjs.js",
"import": "./compat/app-check/dist/index.mjs"
},
"default": "./compat/app-check/dist/index.esm.js"
},
"./compat/auth": {
"node": {
"require": "./compat/auth/dist/index.cjs.js",
"import": "./compat/auth/dist/index.mjs"
},
"default": "./compat/auth/dist/index.esm.js"
},
"./compat/database": {
"node": {
"require": "./compat/database/dist/index.cjs.js",
"import": "./compat/database/dist/index.mjs"
},
"default": "./compat/database/dist/index.esm.js"
},
"./compat/firestore": {
"node": {
"require": "./compat/firestore/dist/index.cjs.js",
"import": "./compat/firestore/dist/index.mjs"
},
"default": "./compat/firestore/dist/index.esm.js"
},
"./compat/functions": {
"node": {
"require": "./compat/functions/dist/index.cjs.js",
"import": "./compat/functions/dist/index.mjs"
},
"default": "./compat/functions/dist/index.esm.js"
},
"./compat/messaging": {
"node": {
"require": "./compat/messaging/dist/index.cjs.js",
"import": "./compat/messaging/dist/index.mjs"
},
"default": "./compat/messaging/dist/index.esm.js"
},
"./compat/performance": {
"node": {
"require": "./compat/performance/dist/index.cjs.js",
"import": "./compat/performance/dist/index.mjs"
},
"default": "./compat/performance/dist/index.esm.js"
},
"./compat/remote-config": {
"node": {
"require": "./compat/remote-config/dist/index.cjs.js",
"import": "./compat/remote-config/dist/index.mjs"
},
"default": "./compat/remote-config/dist/index.esm.js"
},
"./compat/storage": {
"node": {
"require": "./compat/storage/dist/index.cjs.js",
"import": "./compat/storage/dist/index.mjs"
},
"default": "./compat/storage/dist/index.esm.js"
}
},
"repository": {
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"scripts": {
"build": "rollup -c && gulp cdn-type-module-path && yarn build:compat",
"build:compat": "rollup -c compat/rollup.config.js",
"dev": "rollup -c -w",
"test": "echo 'No test suite for firebase wrapper'",
"test:ci": "echo 'No test suite for firebase wrapper'"
},
"dependencies": {
"@firebase/app": "0.7.1",
"@firebase/app-compat": "0.1.2",
"@firebase/app-types": "0.7.0",
"@firebase/auth": "0.18.0",
"@firebase/auth-compat": "0.1.3",
"@firebase/database": "0.12.1",
"@firebase/database-compat": "0.1.1",
"@firebase/firestore": "3.1.0",
"@firebase/firestore-compat": "0.1.3",
"@firebase/functions": "0.7.2",
"@firebase/functions-compat": "0.1.3",
"@firebase/installations": "0.5.1",
"@firebase/messaging": "0.9.1",
"@firebase/messaging-compat": "0.1.1",
"@firebase/polyfill": "0.3.36",
"@firebase/storage": "0.8.3",
"@firebase/storage-compat": "0.1.3",
"@firebase/performance": "0.5.1",
"@firebase/performance-compat": "0.1.1",
"@firebase/remote-config": "0.3.0",
"@firebase/remote-config-compat": "0.1.1",
"@firebase/analytics": "0.7.1",
"@firebase/analytics-compat": "0.1.2",
"@firebase/app-check": "0.4.1",
"@firebase/app-check-compat": "0.1.2",
"@firebase/util": "1.4.0"
},
"devDependencies": {
"rollup": "2.56.3",
"@rollup/plugin-commonjs": "20.0.0",
"@rollup/plugin-node-resolve": "13.0.4",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.30.0",
"rollup-plugin-uglify": "6.0.4",
"gulp": "4.0.2",
"gulp-sourcemaps": "3.0.0",
"gulp-replace": "1.1.3",
"typescript": "4.2.2"
},
"components": [
"analytics",
"app",
"app-check",
"auth",
"auth/cordova",
"auth/react-native",
"functions",
"firestore",
"firestore/lite",
"storage",
"performance",
"remote-config",
"messaging",
"messaging/sw",
"database"
]
}
另一个。 (这是.js文件。)
const firebase = require('firebase');
const config = require('./config');
const db = firebase.initializeApp(config.firebaseConfig);
module.exports = db;
我试着自己修复它,但我不知道在哪里修复它。 我试着在互联网上搜索这个问题,但没有找到。
我该怎么办。你能帮帮我吗?
如果您想看更多内容,可以告诉我。
非常感谢。
推荐答案
将.js
文件更改为
const { initializeApp } = require('firebase/app')
const config = require('./config');
const db = initializeApp(config.firebaseConfig);
module.exports = db;
请参阅firebase
这篇关于INTERNAL/MODULES/cjs/loader.js:456引发e;^错误[ERR_PACKAGE_PATH_NOT_EXPORTED]:未在中定义导出(&Q)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文