我试图npm install在一个相当过时的项目上运行并不断遇到 NPM 依赖错误。我之前在各种项目中遇到过数百个这样的错误,但我还没有找到关于如何阅读它们的良好指南。该线程最接近,但并没有真正描述一般情况,这些文档帮助我理解依赖项的底层结构,但并不能真正帮助我调试。
下面是我现在遇到的错误,从底部开始,我的解释是@aws-amplify/ui-react@1.2.26require react-dom@">=16.7.0",但除此之外我不遵循。它看起来像react-dom@18.2.0require react@"^18.2.0",但我不明白这是如何相关的,因为它react-dom甚至不是我的项目中的依赖项(至少没有明确声明)。
我认为缩进块意味着错误来自嵌套依赖项,但我真的不知道该怎么做。同样,上面的错误也与 相关@aws-amplify/ui-react@1.2.26,但我无法判断它是否导致下面的错误,反之亦然(或者也许它们完全无关?)。
我希望获得 1) 有关如何将 NPM 依赖项错误解读为可操作步骤的一般建议,以及 2) 有关如何修复此特定错误的建议。
另请注意,我已经尝试过npm update @aws-amplify/ui-react@1.2.26,但遇到了类似的错误。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: myapp@0.0.1
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"17.0.1" from the root project
npm ERR! peer react@">= 16.7.0" from @aws-amplify/ui-react@1.2.26
npm ERR! node_modules/@aws-amplify/ui-react …Run Code Online (Sandbox Code Playgroud) 考虑以下代码:
class Foo:
@staticmethod
def is_room_member(invitee, msg):
return invitee in msg.frm.room.occupants
Run Code Online (Sandbox Code Playgroud)
我想测试该方法is_room_member,其中invitee是一个字符串,并且
occupants是一个字符串列表。
如果invitee = 'batman'且occupants = ['batman', 'superman']该方法is_room_member返回True。
msg是需要模拟的对象,以便我可以测试这个方法。
我如何测试这个方法,因为它需要这个msg具有嵌套属性的对象?
我希望测试是这样的:
class Testing(unittest.TestCase):
def test_is_room_member(self):
occupants = ['batman', 'superman']
# mocking
# msg = MagicMock()
# msg.frm.room.occupants = occupants
self.assertTrue(Foo.is_room_member('batman', msg))
Run Code Online (Sandbox Code Playgroud) 我一直在为下面的功能而苦苦挣扎,因为它的console.log()语句没有出现在Firebase日志中。如果我拿出一切开始与db.collection通话时,console.log()在顶部报表会显示出来,但一旦我补充一点,db.collection通话,没有了的console.log()报表火力地堡的日志显示出来。
我对JavaScript并不是很熟悉(我通常使用Python进行后端编程),因此这可能与Promises的工作方式有关。我正在研究这个。
知道发生了什么吗?
exports.purchaseItem = functions.https.onCall((data, context) => {
console.log('data:')
console.log(data)
let lbcCustomerStripeToken = data.lbcCustomerStripeToken
let lbcStoreId = data.lbcStoreId
let amount = data.amount
console.log('lbcCustomerStripeToken:')
console.log(lbcCustomerStripeToken)
console.log('lbcStoreId:')
console.log(lbcStoreId)
console.log('amount:')
console.log(amount)
let lbcFee = Math.round(amount * 0.02)
db.collection('stores').doc(lbcStoreId).get().then(lbcStore => {
if (!lbcStore.exists) {
console.log('No such product!');
} else {
console.log('Document data:', product.data());
}
console.log('storeInfo:')
console.log(lbcStore.data())
return {message: 'Success'}
})
.catch((error) => {
console.log(error);
});
};
Run Code Online (Sandbox Code Playgroud) javascript node.js firebase firebase-realtime-database google-cloud-functions
我有一个 Vue.js 项目,直到几分钟前才正常运行。npm run build当我停止工作时,我正在尝试添加一个新的小功能,Syntax Error如下所示。我花了一些时间仔细阅读它,但在我看来,Unexpected token除了在 App.vue 中之外,没有给出任何关于其实际位置的线索。
我怀疑我可能最终可以通过取出代码来让它工作,直到我弄清楚它是什么造成的,但是处理这些错误消息的首选方法是什么?它们似乎没有帮助,每次我得到 a 时提取代码Syntax Error都会比立即知道错误在哪里要慢得多。
| building for production...
Starting to optimize CSS...
Processing css/app.b78de1b1e52d045850f3f8ef25eab789.css...
Processed css/app.b78de1b1e52d045850f3f8ef25eab789.css, before: 2077, after: 2009, ratio: 96.73%
Hash: 463db738399a4df0bc89
Version: webpack 2.6.1
Time: 7211ms
Asset Size Chunks Chunk Names
js/app.46d986e313fa2c015cd0.js 5.62 kB 0 [emitted] app
js/vendor.bf7e840e23d2fcdbebe0.js 141 kB 1 [emitted] vendor
js/manifest.c323c0be7462a1c8da87.js 1.51 kB 2 [emitted] manifest
css/app.b78de1b1e52d045850f3f8ef25eab789.css 2.01 kB 0 [emitted] app
js/app.46d986e313fa2c015cd0.js.map 26 kB 0 [emitted] …Run Code Online (Sandbox Code Playgroud) 我有两个模型:用户和组。
用户可以在一个组中,因此:
class User(db.Model):
# other fields
group_id = db.Column(db.Integer(), db.ForeignKey('group.id'))
Run Code Online (Sandbox Code Playgroud)
但另一方面,我也会有一些有关创建该特定组的用户的信息:
class Group(db.Model):
# other fields
users = db.relationship("User", backref='group')
created_by = db.Column(db.Integer(), db.ForeignKey('user.id'))
Run Code Online (Sandbox Code Playgroud)
结果是:
sqlalchemy.exc.CircularDependencyError: Can't sort tables for DROP; an unresolvable foreign key dependency exists between tables: group, user. Please ensure that the ForeignKey and ForeignKeyConstraint objects involved in the cycle have names so that they can be dropped using DROP CONSTRAINT.
Run Code Online (Sandbox Code Playgroud)
我试过了use_alter=True,但它给了我:
sqlalchemy.exc.CompileError: Can't emit DROP CONSTRAINT for constraint ForeignKeyConstraint(
Run Code Online (Sandbox Code Playgroud) 我正在帮助某人启动并运行 Django + Vue 应用程序,我们遇到的一个问题是如何让 Vue 应用程序热重载,同时又能够与本地 Django 服务器交互。
在生产中,Django 服务器将为 Vue 应用程序提供服务,并将npm run buildVue 应用程序的资产放入 Django 项目templates/和static/文件夹中。
当我们运行 Django 服务器 ( python manage.py runserver) 时,服务器运行在localhost:8000。当我们运行时npm run serve(为了获得热重载的好处),Vue 应用程序将在 处提供服务localhost:8080。如果我从 Vue 应用程序向 发出 GET 请求/exampleEndpoint,它会转到localhost:8080/exampleEndpoint,因此不会访问 Django 服务器。
让 Vue 应用程序与 Django 应用程序一起使用的正确方法是什么?
我想在调用 @jwt_required 时向令牌添加额外的验证。我想验证其中一项声明。我可以用 JWTManager 做到这一点吗?
目前我的代码只是调用:
jwt = JWTManager(app)
Run Code Online (Sandbox Code Playgroud)
我用以下方法装饰功能: @jwt_required
背景:
Tools-->Options-->Authentication设置页面中只列出了我的主要 GitHub 帐户。问题:
我意识到unittest.mock对象现在有assert_not_called可用的方法,但是我正在寻找的是assert_not_called_with。有没有类似的东西?我在Google上查看时没有看到任何内容,当我尝试仅使用mock_function.assert_not_called_with(...)它时便引发了AttributeError,表示该功能不存在该名称。
with self.assertRaises(AssertionError):
mock_function.assert_called_with(arguments_I_want_to_test)
Run Code Online (Sandbox Code Playgroud)
这可以工作,但是如果我要打几个这样的调用,会使代码混乱。
如果我看到如下的堆栈跟踪:
Exception in thread Thread-101:
Traceback (most recent call last):
(...)
Run Code Online (Sandbox Code Playgroud)
“线程101”是否必然意味着有101个活动/打开/性能下降的线程?还是这些名称像数据库中的ID一样工作,即使删除(关闭)了较旧的记录(线程),该数字也始终会上升?
python ×6
node.js ×2
vue.js ×2
dependencies ×1
django ×1
firebase ×1
flask ×1
javascript ×1
jwt ×1
mocking ×1
npm ×1
python-3.x ×1
react-native ×1
reactjs ×1
sqlalchemy ×1
unit-testing ×1
vue-cli ×1
vue-loader ×1
vuejs2 ×1