问题描述
我想向服务器添加身份验证。我在这里关注文档:https://loopback.io/doc/en/lb4/Authentication-tutorial.html
添加此注释@authenticate('jwt')
时,出现以下错误:
Cannot start the application. TypeError: core_1.injectable is not a function
at Object.<anonymous> (C:\Users\mshaham\projects\mevolve\user-service\node_modules\@loopback\authentication\src\providers\auth-action.provider.ts:116:2)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\mshaham\projects\mevolve\user-service\node_modules\@loopback\authentication\src\providers\index.ts:6:1)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\xxxxx\projects\xxxx\user-service\node_modules\@loopback\authentication\src\authentication.component.ts:8:1)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
解决方法
Node.js v13不受LoopBack 4或the Node.js team themselves的正式支持。还建议您坚持使用偶数或LTS版本。
将Node.js运行时更改为v10
,v12
或v14
。
我发现了问题所在。在安装回送核心后几周,我安装了回送身份验证程序包。同时,核心软件包发布了一些重大更改。
因此,我所要做的就是使用for heldout_dataset in os.listdir():
# Create model
base_model = tf.keras.applications.Xception(input_shape=IMG_SHAPE,include_top=False,weights='imagenet')
# (Etc,adding layers)
model = tf.keras.Model(inputs,outputs)
# (Etc,loading some data that is not held out (ie,not the 'Fold'))
train_data = tf.keras.preprocessing.image_dataset_from_directory(....)
val_data = tf.keras.preprocessing.image_dataset_from_directory(....)
model.fit(train_data,val_data)
# (Etc,making predictions)
# Clear Everything
del train_data
del model
del base_model
del val_data
tf.keras.backend.clear_session()
更新我的软件包并解决了问题!