我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no):
输入yes后报错
Error: Cannot find module 'webpack-cli'
Require stack:
- C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:143:5
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\webpack\\bin\\webpack.js'
]
}
解决办法:输入命令npm install webpack-cli -g全局安装一下webpack-cli
再次运行webpack命令打包,出现新错误
F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\bin\cli.js:137
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
^
TypeError: Cannot read property 'presetToOptions' of undefined
at processOptions (F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\bin\cli.js:137:57)
at F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\bin\cli.js:364:3
at Object.parse (F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\node_modules\yargs\yargs.js:567:18)
at F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\bin\cli.js:49:8
at Object.<anonymous> (F:\myweb\alice\vue\vue-cms\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at module.exports (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\import-local\index.js:16:66)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\bin\cli.js:15:6
at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11
解决办法:根据错误提示信息,打开node_modules\webpack-cli\bin\cli.js,第137行,把const statsPresetToOptions = require("webpack").Stats.presetToOptions;中间Stats下标的这个.删掉。
保存后再次运行webpack就成功了!
发布的网页,自己跑完全没问题,到了用户那出了问题,js报错为:Uncaught SyntaxError: Unexpected token =仔细查看了下代码,没有任何问题,测试了下,在chrome 45.0.2454.85下会报这个错,方法参数不能带默认值。
本文将为您描述如何解决 eharts.js报错 Uncaught TypeError: Cannot read property getAttribute of null 的问题,根据报错信息查找原因发现是因为 实例化 echarts 的元素不存在(未找到指定的元素)
build-url 是一个将对象转换为url字符串的小工具,一般的使用方法为:使用npm安装的build-url在使用时,微信开发者工具会报错 buildUrl undefined错误,跟踪代码发现 是下面代码抛出了异常
最近使用THREE.js在场景中添加了30个左右castShadow的光源,然后在控制台报错:本文记录下这个报错的原因。
内容以共享、参考、研究为目的,不存在任何商业目的。其版权属原作者所有,如有侵权或违规,请与小编联系!情况属实本人将予以删除!