![](/img/trans.png)
[英]Problem with React Joyride on production Cannot read properties of undefined (reading '0')
[英]Problem with launching application in NX monorepo: (cannot read undefined (reading 'projects')
我在 NX monorepo 中有一個項目(雜貨店)使用 nestjs 等。 該應用程序是一個嚴格的后端 api。我想添加一個前端,為此我將反應拖到項目中。 在 monorepo 中生成一個新項目后 ( nx g @nrwl/react:app grocery-shop-webapp
) - 我無法運行任何一個 ( nx serve grocery-shop
)。
我收到一條錯誤消息:
NX 無法讀取未定義的屬性(讀取“項目”)
我的 nx.json 文件代碼如下所示:
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "grocery-shop",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"accessToken": "NjYzNzg4YjMtYjM1ZC00M2NkLThhNzAtZWE2NzM4ZjhiNWUzfHJlYWQtd3JpdGU="
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"e2e": {
"inputs": ["default", "^production"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
],
"sharedGlobals": ["{workspaceRoot}/babel.config.json"]
},
"defaultProject": "grocery-shop",
"generators": {
"@nrwl/react": {
"application": {
"style": "css",
"linter": "eslint",
"bundler": "webpack",
"babel": true
},
"component": {
"style": "css"
},
"library": {
"style": "css",
"linter": "eslint"
}
}
}
}
所以我決定在這個文件中手動實現“項目”選項。
...
"npmScope": "grocery-shop",
"projects": {
"grocery-shop": {
"root": "apps/grocery-shop",
"tags": []
},
"grocery-shop-webapp": {
"root": "apps/grocery-shop-webapp",
"tags": []
}
}
...
所以現在當我嘗試運行nx serve grocery-shop
時,我收到一條錯誤消息:
NX 從 Nx 13 開始,項目配置應從 nx.json 移動到 workspace.json/project.json。 請運行“nx format”來解決這個問題。
NX 找不到任務雜貨店的配置:服務
我會提到“ nx format
”沒有改善任何東西,錯誤仍然存在。
你們能幫我運行這兩個應用程序嗎?
編輯: nx report
output:
npm : 9.2.0
nx : 15.3.3
@nrwl/angular : Not Found
@nrwl/cypress : 15.6.2
@nrwl/detox : Not Found
@nrwl/devkit : 15.3.3
@nrwl/esbuild : Not Found
@nrwl/eslint-plugin-nx : 15.3.3
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 15.6.2
@nrwl/js : 15.6.2
@nrwl/linter : 15.3.3
@nrwl/nest : 15.4.2
@nrwl/next : Not Found
@nrwl/node : 15.3.3
@nrwl/nx-cloud : 15.0.2
@nrwl/nx-plugin : Not Found
@nrwl/react : 15.6.2
@nrwl/react-native : Not Found
@nrwl/rollup : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : Not Found
@nrwl/web : Not Found
@nrwl/webpack : 15.3.3
@nrwl/workspace : 15.3.3
typescript : 4.9.4
解決方案:正如@Craigory Coppola 正確指出的那樣,我使用nx migrate latest
命令來更新 NX 及其依賴項的版本 - 我的依賴項版本不匹配。
這看起來像是您的 nrwl/nx 包版本可能不匹配。 你能運行nx report
嗎?
它們應該都是一樣的,除了 nx cloud
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.