我创建了一个新项目,按照以下说明完全空白: https://developer.microsoft.com/en-us/fabric#/get-started 请按照步骤1-4
应用程序运行正常。
一旦我在webpack上运行npm
然后我收到此错误
我的package.json
export PATH=/Users/username/anaconda3/bin:$PATH
错误是这样的:
{
"name": "lulo",
"version": "0.1.0",
"private": true,
"dependencies": {
"office-ui-fabric-react": "^6.157.0",
"react": "^16.8.4",
"react-adal": "^0.4.22",
"react-dom": "^16.8.4",
"react-scripts-ts": "3.1.0",
"redux": "^4.0.1"
},
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
},
"devDependencies": {
"@types/jest": "^24.0.11",
"@types/node": "^11.11.3",
"@types/react": "^16.8.8",
"@types/react-adal": "^0.4.1",
"@types/react-dom": "^16.8.2",
"typescript": "^3.3.3333",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
}
}
并且日志文件具有此
Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
Failed to compile.
Cannot read property 'thisCompilation' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lulo@0.1.0 build: `react-scripts-ts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lulo@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/luisvalencia/.npm/_logs/2019-03-19T21_18_01_997Z-debug.log
答案 0 :(得分:2)
此线程的答案是:
https://github.com/facebook/create-react-app/issues/4076
基本上,删除node_modules并从package.json依赖项中删除webpack,然后删除npm install
。有些人通过使用yarn而不是npm来解决。
答案 1 :(得分:1)
我很努力地解决了这个错误一段时间。我的问题是由于传递依赖。尽管在我的项目package.json中没有明确提到“ webpack”作为依赖项,但我在package-lock.json中发现了两个版本的“ webpack”。其中一个由“ react-scripts”使用,另一个由“ react-nbsp”使用,我在package.json中已将其作为依赖项使用,并用于在React JSX中获得不间断的空间。
我从package.json中删除了“ react-nbsp”,删除了node-modules,package-lock.json并运行了该应用程序。它开始没有错误,并且运行良好。