Javascript 无法读取未定义的-react脚本的属性“thisCompilation”

Javascript 无法读取未定义的-react脚本的属性“thisCompilation”,javascript,reactjs,typescript,webpack,create-react-app,Javascript,Reactjs,Typescript,Webpack,Create React App,我使用以下说明创建了一个完全空白的新项目: 遵循步骤1-4 该应用程序运行良好 一旦我运行npm,我就可以使用webpack 然后我得到了这个错误 mypackage.json { "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", "reac

我使用以下说明创建了一个完全空白的新项目: 遵循步骤1-4

该应用程序运行良好

一旦我运行npm,我就可以使用webpack

然后我得到了这个错误

mypackage.json

{
"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 info it worked if it ends with ok
1 verbose cli [ '/Users/x/.nvm/versions/node/v10.0.0/bin/node',
1 verbose cli   '/Users/x/.nvm/versions/node/v10.0.0/bin/npm',
1 verbose cli   'run-script',
1 verbose cli   'build' ]
2 info using npm@5.6.0
3 info using node@v10.0.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle lulo@0.1.0~prebuild: lulo@0.1.0
6 info lifecycle lulo@0.1.0~build: lulo@0.1.0
7 verbose lifecycle lulo@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle lulo@0.1.0~build: PATH: /Users/x/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/x/Lulo/lulo/node_modules/.bin:/Users/x/.nvm/versions/node/v10.0.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle lulo@0.1.0~build: CWD: /Users/x/Lulo/lulo
10 silly lifecycle lulo@0.1.0~build: Args: [ '-c', 'react-scripts-ts build' ]
11 silly lifecycle lulo@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle lulo@0.1.0~build: Failed to exec build script
13 verbose stack Error: lulo@0.1.0 build: `react-scripts-ts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/x/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/Users/x/.nvm/versions/node/v10.0.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:947:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:236:5)
14 verbose pkgid lulo@0.1.0
15 verbose cwd /Users/luisvalencia/Lulo/lulo
16 verbose Darwin 18.0.0
17 verbose argv "/Users/x/.nvm/versions/node/v10.0.0/bin/node" "/Users/x/.nvm/versions/node/v10.0.0/bin/npm" "run-script" "build"
18 verbose node v10.0.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error lulo@0.1.0 build: `react-scripts-ts build`
22 error Exit status 1
23 error Failed at the lulo@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

此线程的答案是:


基本上,删除node_模块并从package.json依赖项中删除webpack,然后安装npm。有些人用纱线代替npm解决了这个问题。

这条线的答案是:


基本上,删除node_模块并从package.json依赖项中删除webpack,然后安装npm。有些人用纱线代替npm解决了这个问题。

我也曾一度努力解决这个问题。在我的例子中,问题是由于可传递依赖性。虽然在我的project package.json中没有明确提到webpack是依赖项,但我在package-lock.json中发现了两个版本的webpack。一个由react脚本使用,另一个由react nbsp使用,我在package.json中提到过它作为依赖项,并使用它在react JSX中获得不间断的空间


我从package.json中删除了react nbsp,删除了节点模块package-lock.json并运行了应用程序。它一开始就没有出错,而且运行得很好。

我也曾在相当长的一段时间里努力解决这个错误。在我的例子中,问题是由于可传递依赖性。虽然在我的project package.json中没有明确提到webpack是依赖项,但我在package-lock.json中发现了两个版本的webpack。一个由react脚本使用,另一个由react nbsp使用,我在package.json中提到过它作为依赖项,并使用它在react JSX中获得不间断的空间


我从package.json中删除了react nbsp,删除了节点模块package-lock.json并运行了应用程序。它启动时没有出现错误,工作正常。

我为什么要删除webpack>?我需要它。我为什么要删除webpack>?我需要它。