npm run build 报错!Build failed with errors
程序员文章站
2022-05-30 09:15:07
...
npm run build 报错!Build failed with errors.
[[email protected]_0_9_centos client]# npm run build
> [email protected] build /www/wwwroot/fenturuning/client
> vue-cli-service build
⠸ Building for production...
ERROR Failed to compile with 1 errors 8:44:28 AM
error in ./src/router/index.js
Module build failed (from ./node_modules/[email protected]@thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Cannot read property 'range' of null
at PoolWorker.fromErrorObj (/www/wwwroot/fenturuning/client/node_modules/[email protected]@thread-loader/dist/WorkerPool.js:262:12)
at /www/wwwroot/fenturuning/client/node_modules/[email protected]@thread-loader/dist/WorkerPool.js:204:29
at SourceCode.getTokenBefore (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/token-store/index.js:303:18)
at checkSpacingBefore (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/rules/template-curly-spacing.js:52:42)
at TemplateElement (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/rules/template-curly-spacing.js:117:17)
at /www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/util/safe-emitter.js:47:58
at Array.forEach (<anonymous>)
at Object.emit (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/util/safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (/www/wwwroot/fenturuning/client/node_modules/[email protected]@eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
@ ./src/main.js 35:0-30 38:12-18 44:10-16
@ multi ./src/main.js
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-01-03T00_44_28_399Z-debug.log
报错显示:./src/router/index.js 文件错误;
是在看不出哪里的错误;
求大神指点!!
下面是文档全部内容;
/**
* Vue Router
*
* @library
*
* https://router.vuejs.org/en/
*/
// Lib imports
import Vue from 'vue'
import VueAnalytics from 'vue-analytics'
import Router from 'vue-router'
import Meta from 'vue-meta'
// Routes
import paths from './paths'
function route (path, view, name) {
return {
name: name || view,
path,
component: (resovle) => import(
`@/views/${view}.vue`
).then(resovle),
}
}
Vue.use(Router)
// Create a new router
const router = new Router({
mode: 'history',
routes: paths.map(path => route(path.path, path.view, path.name)).concat([
{ path: '*', redirect: '/dashboard' }
]),
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
}
if (to.hash) {
return { selector: to.hash }
}
return { x: 0, y: 0 }
}
})
Vue.use(Meta)
// Bootstrap Analytics
// Set in .env
// https://github.com/MatteoGabriele/vue-analytics
if (process.env.GOOGLE_ANALYTICS) {
Vue.use(VueAnalytics, {
id: process.env.GOOGLE_ANALYTICS,
router,
autoTracking: {
page: process.env.NODE_ENV !== 'development'
}
})
}
export default router
求解决,好几天了!!
推荐阅读
-
基于vue-cli npm run build之后vendor.js文件过大的解决方法
-
vue中Npm run build 根据环境传递参数方法来打包不同域名
-
解决 React-Native mac 运行报错 error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build log
-
Vue -- vue-cli(vue脚手架) npm run build打包优化
-
vue component 中引入less文件报错 Module build failed
-
iOS开发Archive报错Build Failed不显示打包界面
-
vue 动态设置img的src地址无效,npm run build 后找不到文件的解决
-
Unity Hub安装Android Build Support报错:Failed to delete old Unity Android Supprtinstallation files
-
关于vue的npm run dev和npm run build的区别介绍
-
vue打包npm run build时候界面报错的解决