美文网首页
mp-vue微信小程序报错:if (!cachedModule.

mp-vue微信小程序报错:if (!cachedModule.

作者: 小马将过河 | 来源:发表于2022-07-13 23:59 被阅读0次

项目版本信息(package.json文件全部内容)

{
  "name": "my-project",
  "version": "1.0.0",
  "description": "A Mpvue project",
  "author": "Tony <961505161@qq.com>",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "start": "node build/dev-server.js",
    "build": "node build/build.js",
    "lint": "eslint --ext .js,.vue src"
  },
  "dependencies": {
    "flyio": "^0.6.0",
    "fundebug-wxjs": "^1.1.0",
    "moment": "^2.22.2",
    "mpvue": "^1.0.11",
    "mpvue-router-patch": "^0.2.1",
    "vue-bus": "^1.2.0",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "babel-core": "^6.22.1",
    "babel-eslint": "^8.2.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chalk": "^2.4.0",
    "connect-history-api-fallback": "^1.3.0",
    "copy-webpack-plugin": "^4.5.1",
    "css-loader": "^0.28.11",
    "cssnano": "^3.10.0",
    "eslint": "^4.19.1",
    "eslint-config-airbnb-base": "^12.1.0",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-import-resolver-webpack": "^0.9.0",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-html": "^4.0.3",
    "eslint-plugin-import": "^2.11.0",
    "eslint-plugin-node": "^6.0.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.16.3",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "^1.1.11",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "glob": "^7.1.2",
    "html-webpack-plugin": "^3.2.0",
    "http-proxy-middleware": "^0.18.0",
    "mpvue-entry": "^2.0.0-rc.10",
    "mpvue-loader": "1.0.13",
    "mpvue-template-compiler": "^1.0.11",
    "mpvue-webpack-target": "^1.0.0",
    "node-sass": "^4.14.1",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^2.0.0",
    "portfinder": "^1.0.13",
    "postcss-loader": "^2.1.4",
    "postcss-mpvue-wxss": "^1.0.0",
    "prettier": "~1.12.1",
    "px2rpx-loader": "^0.1.10",
    "relative": "^3.0.2",
    "rimraf": "^2.6.0",
    "sass-loader": "^7.0.3",
    "semver": "^5.3.0",
    "shelljs": "^0.8.1",
    "uglifyjs-webpack-plugin": "^1.2.5",
    "url-loader": "^1.0.1",
    "vue-style-loader": "^4.1.0",
    "webpack": "^3.11.0",
    "webpack-bundle-analyzer": "^2.2.1",
    "webpack-dev-middleware-hard-disk": "^1.12.0",
    "webpack-merge": "^4.1.0",
    "webpack-mpvue-asset-plugin": "^0.1.1"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

npm install 没有错误

npm run dev错误如下

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:48:22]
$ npm run dev

> my-project@1.0.0 dev
> node build/dev-server.js

internal/modules/cjs/loader.js:762
    if (!cachedModule.loaded) {
                      ^

TypeError: Cannot read property 'loaded' of null
    at Function.Module._load (internal/modules/cjs/loader.js:762:23)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at parsePages (/Users/mahaiqiang/git/redcreation/zhiliang/node_modules/mpvue-entry/lib/parser.js:41:17)
    at Function.getEntry (/Users/mahaiqiang/git/redcreation/zhiliang/node_modules/mpvue-entry/lib/index.js:22:13)
    at Object.<anonymous> (/Users/mahaiqiang/git/redcreation/zhiliang/build/webpack.base.conf.js:72:22)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/mahaiqiang/git/redcreation/zhiliang/build/webpack.dev.conf.js:5:25)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:48:46] C:1

当前工作环境

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:54:10]
$ node -v
v14.18.2

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:56:05]
$ npm -v
8.3.2

解决错误

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:52:02] C:1
$ npm cache clean --force
npm WARN using --force Recommended protections disabled.

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:52:06]
$ npm i mpvue-entry@next -D
npm WARN deprecated fsevents@1.2.4: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

up to date in 4s

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:52:18]
$ npm install
npm WARN deprecated fsevents@1.2.4: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

up to date in 3s

重新启动

# mahaiqiang @ mahaiqiangdeMacBook-Air in ~/git/redcreation/zhiliang on git:master x [23:52:24]
$ npm run dev

> my-project@1.0.0 dev
> node build/dev-server.js

(node:26589) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:26589) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:26589) Warning: Accessing non-existent property 'which' of module exports inside circular dependency


 DONE  Compiled successfully in 2505ms                                                                                             下午11:52:32



 WAIT  Compiling...                                                                                                                下午11:52:32



 DONE  Compiled successfully in 119ms                                                                                              下午11:52:32

总结:

没有弄明白原因,但是估计起作用的是下面这句,也就是到头来就是清了个缓存,希望读者没有被骗,反正我的环境就这么OK的,困扰了两个月了。

 npm cache clean --force

但是从git diff上看的话,mpvue-entry的版本也发生了变化

"mpvue-entry": "^1.4.7"   ->    "mpvue-entry": "^2.0.0-rc.10",

相关文章

网友评论

      本文标题:mp-vue微信小程序报错:if (!cachedModule.

      本文链接:https://www.haomeiwen.com/subject/huhxirtx.html