Tag Archives: uniapp TypeError: Cannot read property ‘replace’ of undefined

uniapp TypeError: Cannot read property ‘replace’ of undefined

Run the uniapp in webstorm: NPM run dev: H5

The error message is as follows:

D:\uniapp-Project\cga-miniapp-208\4-Invoice>npm run dev:h5

> [email protected] dev:h5 D:\uniapp-Project\cga-miniapp-208\4-Invoice
> cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve

D:\uniapp-Project\cga-miniapp-208\4-Invoice\node_modules\@dcloudio\uni-cli-shared\lib\util.js
:7
const normalizePath = path => (isWin ?path.replace(/\\/g, '/') : path)
                                            ^

TypeError: Cannot read property 'replace' of undefined
    at normalizePath (D:\uniapp-Project\cga-miniapp-208\4-Invoice\node_modules\@dcloudio\uni-
cli-shared\lib\util.js:7:45)
    .........
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! [email protected] dev:h5: `cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-serv
ice uni-serve`
npm ERR! Exit status 7
npm ERR!                                    npm ERR!
npm ERR! Failed at the [email protected] dev:hnpm 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!     C:\Users\admin\AppData\Roaming\npm-cache\_logs\2021-10-29T03_00_03_526Z-debug.log

Solution: download the package where the error is located again

For example, the location of the above error is: node_ modules\@dcloudio\uni- cli-shared\lib\util.js:7:45