(7)taro每日n坑---Error: Cannot find module '@tarojs/plugin-platform-weapp' from

时隔多日再次npm run dev:weapp时报错:

~/Desktop/prosbefore-y/the-end-1/common/min-pro/vshow   cloud-dev  npm run dev:weapp

> vshow@1.0.0 dev:weapp
> npm run build:weapp -- --watch


> vshow@1.0.0 build:weapp
> NODE_ENV=production taro build --type weapp "--watch"

👽 Taro v3.3.12

/Users/q/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/node_modules/resolve/lib/sync.js:81
    var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
              ^

Error: Cannot find module '@tarojs/plugin-platform-weapp' from '/Users/user/Desktop/prosbefore-y/the-end-1/common/min-pro/vshow'
    at Function.resolveSync [as sync] (/Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/node_modules/resolve/lib/sync.js:81:15)
    at /Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/utils/index.js:46:31
    at Array.map (<anonymous>)
    at Object.resolvePresetsOrPlugins (/Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/utils/index.js:45:30)
    at Kernel.resolvePlugins (/Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/Kernel.js:90:36)
    at Kernel.initPresetsAndPlugins (/Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/Kernel.js:81:14)
    at Kernel.<anonymous> (/Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/Kernel.js:40:18)
    at Generator.next (<anonymous>)
    at /Users/user/.nvm/versions/node/v16.3.0/lib/node_modules/@tarojs/cli/node_modules/@tarojs/service/dist/Kernel.js:8:71
    at new Promise (<anonymous>) {
  code: 'MODULE_NOT_FOUND'

解决方法:

// 查看node版本 当前是v16.3.0
nvm ls
// 切换node版本为新建此项目时的版本
nvm install 12.18.3
nvm use 12.18.3

// 安装包
sudo npm i
// 再次执行npm run dev:weapp  成功了
npm run dev:weapp

推荐阅读更多精彩内容