小编Jas*_*son的帖子

Typescript 排除/忽略(不编译) rootDir 中的文件

我正在编写一个 TypeScript/React Web 应用程序,它具有以下顶级目录\n结构:

\n
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 jest.config.ts\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node_modules\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package-lock.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 public\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 webpack.config.js\n
Run Code Online (Sandbox Code Playgroud)\n

所有 TypeScript 源文件都包含在该src/目录中,但我想在编译/类型检查中忽略单个文件(将来可能还会有更多文件)。

\n

我在此文件中遇到错误,但我不想在应用程序中使用该文件。\n我也不想删除该文件,因为它是另一个应用程序使用的模块的一部分。

\n

错误

\n
error TS2307: Cannot find module 'x' or its corresponding type declarations.\n
Run Code Online (Sandbox Code Playgroud)\n

你能帮我做这个吗?这是tsconfig.json我正在使用的文件:

\n

tsconfig

\n
{\n  "compilerOptions": {\n    "allowJs": true,\n    "emitDecoratorMetadata": true,\n    "esModuleInterop": true,\n    "experimentalDecorators": true,\n    "forceConsistentCasingInFileNames": true,\n    "jsx": "react",\n    "module": "es6",\n    "moduleResolution": "node",\n    "outDir": "./dist",\n    "rootDir": "./src",\n    "skipLibCheck": true,\n    "strict": true,\n    "target": "es5"\n  },\n  "exclude": [\n    "dist/",\n    "jest.config.ts",\n    "webpack.config.js"\n  ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n …

configuration compilation transpiler typescript tsc

7
推荐指数
1
解决办法
6372
查看次数

Docker Node Alpine Image构建在node-gyp上失败

我正在尝试对Vue.js应用程序进行Docker化。我正在使用node:10.15-alpineDocker映像作为基础。映像生成失败,并出现以下错误:

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Linux 4.9.125-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp …
Run Code Online (Sandbox Code Playgroud)

node.js npm node-gyp docker alpine-linux

5
推荐指数
4
解决办法
2546
查看次数