1、场景:初始化的项目 运行以下命令npm run dev:h5、npm run dev:weapp报错
npm run dev:h5
npm run dev:weapp
> [email protected] dev:h5 /Users//Desktop/minipro/vshow
> npm run build:h5 -- --watch
> [email protected] build:h5 /Users//Desktop/minipro/vshow
> taro build --type h5 "--watch"
Taro v3.0.7
(node:4716) UnhandledPromiseRejectionWarning: /Users//Desktop/minipro/vshow/node_modules/[email protected]@p-limit/index.js:30
} catch {}
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Module._compile (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:99:24)
at Module._extensions..js (module.js:663:10)
at Object.newLoader [as .js] (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:104:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/Users//Desktop/minipro/vshow/node_modules/[email protected]@terser-webpack-plugin/dist/index.js:26:38)
at Module._compile (module.js:652:30)
at Module._compile (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:99:24)
at Module._extensions..js (module.js:663:10)
at Object.newLoader [as .js] (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:104:7)
(node:4716) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:4716) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2、解决方案:
是node版本问题 不要使用8.12.0 以及 之前的版本
8.11.3是原来的版本
切换到8.12.0之后执行npm run dev:h5
依旧报错
切换到12.18.3之后 执行npm run dev:h5
执行成功
页面起来了
but but but......
还有呢 别走
3、运行npm run dev:weapp
还是报错
> [email protected] dev:weapp /Users//Desktop/minipro/vshow
> npm run build:weapp -- --watch
> [email protected] build:weapp /Users//Desktop/minipro/vshow
> NODE_ENV=production taro build --type weapp "--watch"
Taro v3.0.7
生成 工具配置 /Users//Desktop/minipro/vshow/dist/project.config.json
(node:17961) UnhandledPromiseRejectionWarning: Error: Missing binding /Users//Desktop/minipro/vshow/node_modules/[email protected]@node-sass/vendor/darwin-x64-72/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 12.x
Found bindings for the following environments:
- OS X 64-bit with Node.js 8.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
at module.exports (/Users//Desktop/minipro/vshow/node_modules/[email protected]@node-sass/lib/binding.js:15:13)
at Object. (/Users//Desktop/minipro/vshow/node_modules/[email protected]@node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Module._compile (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.newLoader [as .js] (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (/Users//Desktop/minipro/vshow/node_modules/_@[email protected]@@tarojs/mini-runner/src/webpack/chain.ts:7:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Module._compile (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.newLoader [as .js] (/Users//Desktop/minipro/vshow/node_modules/[email protected]@pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:985:32)
(node:17961) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:17961) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.