Summary of error reports when starting the uniapp cli-based one-click travel project

Question 1. Use hbuilder to run the command, but nothing happens after starting the compilation. Use the command build to end the process by itself.

Solution: Because node16.24 is used, after uninstalling and reinstalling 14.17, multiple versions are used.

The tutorial is as follows

Windows: Use nvm to install multiple versions of node.js_Tips: now using node v16.14.2 (64-bit)-CSDN Blog

 Question 2.


21:31:11.483 Module build failed (from ./node_modules/@vue/cli-service/node_modules/mini-css-extract-plugin/dist/loader.js):
21:31:11.483 ModuleBuildError: Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
21:31:11.496 ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
21:31:11.502  - options has an unknown property 'data'. These properties are valid:
21:31:11.502    object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
21:31:11.505     at validate (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\@dcloudio\vue-cli-plugin-uni\packages\sass-loader\node_modules\schema-utils\dist\validate.js:96:11)
21:31:11.505     at Object.loader (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\@dcloudio\vue-cli-plugin-uni\packages\sass-loader\dist\index.js:36:28)
21:31:11.515     at D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\webpack\lib\NormalModule.js:316:20
21:31:11.515     at D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:367:11
21:31:11.515     at D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:233:18
21:31:11.530     at runSyncOrAsync (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:143:3)
21:31:11.530     at iterateNormalLoaders (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
21:31:11.539     at iterateNormalLoaders (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
21:31:11.540     at D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:236:3
21:31:11.546     at Object.<anonymous> (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
21:31:11.546     at Object.<anonymous> (D:\lfkj\code\uniapp\yjygx-mini-app\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\index.js:60:8)
21:31:11.724  ERROR  Build failed with errors.

Change the configuration of vue.config.js as follows

module.exports = {
    /* css配置 */
    css: {
        loaderOptions: {
            /* 全局引用 scss 文件 */
            sass: {
                additionalData: `@import "@/assets/css/mixin.scss";`
            },
        },
    },
}

Change to additionalData ==》prependData

module.exports = {
    /* css配置 */
    css: {
        loaderOptions: {
            /* 全局引用 scss 文件 */
            sass: {
                prependData: `@import "@/assets/css/mixin.scss";`
            },
        },
    },
}

Solution, the node version is too high

"node-sass": "^4.14.1",
"sass-loader": "^8.0.2",

Question 3.

gyp find PythonERR! find Python Python is not set from command line or npm 

solution

npm install --global --production windows-build-tools

Question 4.

Syntax Error: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.

 Solution, the node version is too high

"node-sass": "^4.14.1",
"sass-loader": "^8.0.2",

The most important step is to delete the package-lock.json file and re-download the dependent packages.

Then, remove the dependent folders in the specified directory

rimraf node_modules

Next, force clear the npm cache

npm cache clean --force

at last,

# It is strongly recommended not to use cnpm to install directly. There will be various weird bugs. You can solve the problem of slow npm installation speed by re-specifying the registry.

npm install --registry=https://registry.npmmirror.com

Guess you like

Origin blog.csdn.net/weixin_40918145/article/details/134278706