我有一个无法编译的React/SPFx项目。下面是package.json:
{
"name": "project-name",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"@fluentui/react": "^8.106.4",
"@microsoft/rush-stack-compiler-4.5": "^0.5.0",
"@microsoft/sp-component-base": "1.18.0",
"@microsoft/sp-core-library": "1.18.0",
"@microsoft/sp-lodash-subset": "1.18.0",
"@microsoft/sp-office-ui-fabric-core": "1.18.0",
"@microsoft/sp-property-pane": "1.18.0",
"@microsoft/sp-webpart-base": "1.18.0",
"@pnp/spfx-controls-react": "^3.15.0",
"jquery": "^3.7.1",
"moment": "^2.29.4",
"office-ui-fabric-react": "^7.204.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"tslib": "2.3.1"
},
"devDependencies": {
"@microsoft/eslint-config-spfx": "1.18.0",
"@microsoft/eslint-plugin-spfx": "1.18.0",
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
"@microsoft/sp-build-web": "1.18.0",
"@microsoft/sp-module-interfaces": "1.18.0",
"@rushstack/eslint-config": "2.5.1",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"@types/webpack-env": "1.18.2",
"ajv": "^6.12.5",
"eslint": "8.7.0",
"eslint-plugin-react-hooks": "4.3.0",
"gulp": "^4.0.2",
"typescript": "4.7.4"
}
}
节点版本:18.18.2
下面是我执行gulp bundle --ship时的错误:
compilation error
如何解决这一问题?
我也试过Node 16.X和14.X,结果都一样。通过重新安装节点模块也是如此。
1条答案
按热度按时间nxowjjhe1#
我终于把SPFX从1.18降级到1.14了:https://github.com/SharePoint/sp-dev-docs/issues/7691
我仍然不明白为什么编译在1.14中有效,而在1.18中无效。
下面是新的package.json文件: