我是TypeScript的新手,我有一些现有的TypeScript项目。
为了更好地理解该项目,我尝试使用TypeDoc。
但是,出现以下错误。
我尝试在similar question之后解决此问题,但没有成功。
谁能告诉我解决这个问题的方法是什么?
internal/modules/cjs/loader.js:1032
throw err;
^
Error: Cannot find module 'typescript'
Require stack:
- /usr/local/lib/node_modules/typedoc/dist/lib/cli.js
- /usr/local/lib/node_modules/typedoc/bin/typedoc
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/usr/local/lib/node_modules/typedoc/dist/lib/cli.js:9:20)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/typedoc/dist/lib/cli.js',
'/usr/local/lib/node_modules/typedoc/bin/typedoc'
]
}
package.json 。
{
"name": "project",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@material-ui/core": "^4.9.9",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.48",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"date-fns": "^2.12.0",
"gray-matter": "^4.0.2",
"next": "^9.3.4",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"remark": "^12.0.0",
"remark-html": "^11.0.1",
"remark-slug": "^6.0.0",
"swr": "^0.2.3",
"three": "^0.115.0"
},
"devDependencies": {
"@types/node": "^13.11.0",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.1",
"eslint-plugin-standard": "^4.0.1",
"typedoc": "^0.17.7",
"typescript": "^3.8.3"
}
}
答案 0 :(得分:2)
尝试执行以下步骤:
typedoc
:> npm uninstall typedoc
npm install typedoc --ignoreCompilerErrors --logger none --save-dev
。typedoc
利用率的文章。答案 1 :(得分:0)
对于遇到此问题的任何人,请通过此命令安装 typescript 模块。
npm install -g typescript
它会帮助你摆脱这个错误