我正在nuxt + nest堆栈上写一个管理面板。
我使用这个模板:https://github.com/stephsalou/nuxt-nest-template
当我在本地工作时,没有与服务器相关的错误,但是当我运行mode build时,ts想要将node_modules中的文件原型化
Package.json
"scripts": {
"nuxt": "nuxt",
"nest": "nest start",
"dev": "cross-env NODE_TYPE=docker IS_NUXT_ENABLED=true nodemon",
"dev:production": "cross-env NODE_TYPE=production IS_NUXT_ENABLED=true nodemon",
"dev:client": "nuxt",
"dev:server": "nodemon",
"build": "NODE_TYPE=production run-s clean:dist compile:server compile:client client:generate copy:.nuxt copy:client copy:config",
"clean:dist": "rimraf dist",
"compile:server/*this script throws an error*/": "tsc --listFiles -p tsconfig.build.json",
"compile:client": "cross-env mode=production nuxt build",
"client:generate": "cross-env mode=production nuxt generate",
"copy:client": "copyfiles -a \\\"client/**/*\\\" dist",
"copy:.nuxt": "copyfiles -a \".nuxt/**/*\" dist",
"copy:config": "copyfiles nuxt.config.ts package.json package-lock.json dist",
"analytics:dev": "NODE_ENV=development webpack --watch --config ./static/js/analytics/webpack",
"analytics:build": "NODE_ENV=production webpack --config ./static/js/analytics/webpack"
},tsconfig
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"outDir": "./dist/server",
"baseUrl": "./",
"skipLibCheck": true,
// "incremental": true,
"lib": ["ESNext", "ESNext.AsyncIterable", "DOM"],
// "esModuleInterop": true,
// "allowJs": true,
// "strict": true,
// "noEmit": true,
"paths": {
"~/*": ["./server/*"],
"@/*": ["./client/*"]
},
"types": ["@types/node", "@nuxt/types", "@types/sequelize"]
},
"exclude": ["node_modules/**/*", ".nuxt", "dist"]
}tsconfig.build
{
"extends": "./tsconfig.json",
"include": [
"server/**/*"
]
}


为什么它可能不起作用?
发布于 2021-10-01 09:00:36
我不认为这与tsconfig有任何关系。库应该包含在编译中,因为它们是应用程序的一部分。添加属性
"skipLibCheck": true是这类错误的多次修复,因为它跳过了对*.d.ts(库文件)的检查。但不是你的情况,因为它在那里。
首先,我会检查节点版本、纱线版本等。
我使用yarn build成功地试用了该模板
node v14.7.0
yarn v1.22.15然后我觉得include和exclude看起来有点奇怪。如果我没记错的话,扩展时include和exclude会被覆盖。因此,您可能需要在两个配置文件中显式指定它们。
I.e
在tsconfig.json中
"exclude": ["node_modules", ".nuxt", "dist"]在tsconfig.build.json中(确保排除测试)
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
"include": ["server"]https://stackoverflow.com/questions/69402934
复制相似问题