tsconfig.json 中的用户定义路径未找到 \xe2\x80\x93 TypesScript 表示 \xe2\x80\xa6\n我已重新初始化整个项目。使用库存 ts 配置,检查每个设置,更新所有内容。它只是不想工作。
\n项目结构:
\n|-./\n|--index.ts\n|--package.json\n|--tsconfig.json\n|--database/\n|---dbOperations/\n|----index.ts\n|--api/\n|---server.ts\nRun Code Online (Sandbox Code Playgroud)\n包.json:
\n|-./\n|--index.ts\n|--package.json\n|--tsconfig.json\n|--database/\n|---dbOperations/\n|----index.ts\n|--api/\n|---server.ts\nRun Code Online (Sandbox Code Playgroud)\ntsconfig.json(带路径的 tsc --init 之后的初始配置):
\n{\n "name": "name",\n "version": "0.1.0",\n "private": true,\n "description": "desc.",\n "main": "index.ts ",\n "scripts": {\n "test": "jest --config jest.config.json",\n "tsnode": "ts-node index.ts",\n "lint": "eslint \'**/*.ts\' --ignore-pattern node_modules/",\n },\n "license": "ISC",\n "devDependencies": {\n "@babel/core": "^7.15.0",\n "@babel/preset-env": "^7.15.0",\n "@babel/preset-typescript": "^7.15.0",\n "@types/cors": "^2.8.12",\n "@types/express": "^4.17.13",\n "@types/jest": "^27.0.1",\n "@typescript-eslint/eslint-plugin": "^4.32.0",\n "@typescript-eslint/parser": "^4.32.0",\n "eslint": "^7.32.0",\n "jest": "^27.1.0",\n "nodemon": "^2.0.12",\n "ts-jest": "^27.0.5",\n "ts-node": "^10.1.0",\n "typescript": …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 next@11.1.2 和 webpack v5,并在修复 mp3 加载方面卡住了几个小时。我尝试了 stack 和 GitHub 上的其他几个解决方案。他们都不为我工作。
Type error: Cannot find module 'public/sounds/bighit.mp3' or its corresponding type declarations.
14 |
15 | // Assets
> 16 | import sound_bighit from "public/sounds/bighit.mp3"
| ^
info - Checking validity of types .%
Run Code Online (Sandbox Code Playgroud)
这是我最后的 webpack 配置:
const path = require('path')
const SRC = path.resolve(__dirname, 'public/sounds/')
module.exports = {
webpack: (config, { }) => {
config.module.rules.push({
test: /\.mp3$/,
incluse: SRC,
use: {
loader: 'file-loader',
options: {
name: '[name].[contenthash].[ext]',
outputPath: 'public/sounds/', …Run Code Online (Sandbox Code Playgroud)