如何解决“TypeError:在npm安装期间无法读取未定义的属性(阅读'lookup')”

k7fdbhmy  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(90)

我尝试在一个新克隆的angular项目上进行npm安装,npm安装成功,但是当使用ng s调用应用程序时,我遇到了下面的node_modules错误。这和Node js版本有关系吗?

\node_modules\express\lib\response.js:789
        var charset = mime.charsets.lookup(value.split(';')[0]);
                                    ^

TypeError: Cannot read properties of undefined (reading 'lookup')
    at ServerResponse.header (C:\Users\N121075\class-ui\node_modules\express\lib\response.js:789:37)
    at setHeaderForResponse (C:\Users\N121075\class-ui\node_modules\webpack-dev-server\node_modules\webpack-dev-middleware\dist\utils\compatibleAPI.js:94:9)
    at processRequest (C:\Users\N121075\class-ui\node_modules\webpack-dev-server\node_modules\webpack-dev-middleware\dist\middleware.js:142:11)
    at ready (C:\Users\N121075\class-ui\node_modules\webpack-dev-server\node_modules\webpack-dev-middleware\dist\utils\ready.js:17:5)
    at middleware (C:\Users\N121075\class-ui\node_modules\webpack-dev-server\node_modules\webpack-dev-middleware\dist\middleware.js:69:5)
    at Layer.handle [as handle_request] (C:\Users\N121075\class-ui\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:328:13)
    at C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:286:9
    at Function.process_params (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:346:12)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:280:10)
    at Server.setHeaders (C:\Users\N121075\class-ui\node_modules\webpack-dev-server\lib\Server.js:2944:5)
    at Layer.handle [as handle_request] (C:\Users\N121075\class-ui\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:328:13)
    at C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:286:9
    at param (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:365:14)
    at param (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:376:14)
    at Function.process_params (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:421:3)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\index.js:280:10)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:136:14)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)
    at C:\Users\N121075\class-ui\node_modules\webpack-dev-server\lib\Server.js:1948:18
    at Layer.handle [as handle_request] (C:\Users\N121075\class-ui\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:144:13)
    at next (C:\Users\N121075\class-ui\node_modules\express\lib\router\route.js:140:7)

Node.js v18.14.0

下面是安装的版本:Angular CLI:15.2.9节点:18.14.0包管理器:npm 9.3.1 OS:win32 x64

jhiyze9q

jhiyze9q1#

您可以尝试使用npm清理缓存一次,如下所示:

npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm install

相关问题