create-react-app 构建失败,警告:"path"参数必须是字符串类型,接收到的值为null,

wtlkbnrh  于 5个月前  发布在  React
关注(0)|答案(2)|浏览(66)

我无法为这个项目提供可复现的错误,因为它是一个私有项目。然而,我正在使用react-scripts 5.0.1和typescript 4.8.4。

描述错误

构建失败,报错信息为:

❯ env CI=true npm run build

> packages.dev.bloomberg.com@1.0.0 build
> react-scripts build

Creating an optimized production build...

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

The "path" argument must be of type string. Received null

The "path" argument must be of type string. Received null

The "path" argument must be of type string. Received null

The "path" argument must be of type string. Received null

尽管如此,错误信息中并没有提到路径和位置🤔

waxmsbnn

waxmsbnn1#

如果构建过程中有任何位于build/static/js的文件,构建就会失败。

8iwquhpp

8iwquhpp2#

我收到了这个错误信息:

Failed to compile.

p.replace is not a function

手动删除'build'文件夹,然后重新构建。
也许cra应该使用webpack 5的output.clean功能来清理构建文件夹。

相关问题