![](/img/trans.png)
[英]node.js npm package installation error: ENOENT: no such file or directory
[英]Node.js: Error “Exported external package typings file”
簡而言之:
如果我做“ import mongoose = require(“ mongoose”);” 然后輸入execute gulp我得到:
server/categories/categories.model.ts(1,29): error TS2656:
Exported external package typings file
'/vagrant/node_modules/mongoose/index.ts' is not a module.
Please contact the package author to update the package definition.
在Visual Studio Code中,如果我將鼠標懸停,則消息是相同的,但是另一方面,它使用類型定義,因為我可以正常解析我的貓鼬模塊。 我不明白為什么它認為index.ts應該是類型定義。
我不確定這些信息是否足夠,因此請告知我。
提前致謝。
一些摘錄:
gulpfile.js
var tsProject = tsc.createProject("tsconfig.json"); gulp.task("build", function() { return gulp.src([ "server/**/**.ts", "typings/main.d.ts" ]) .pipe(tsc(tsProject)) .js.pipe(gulp.dest("server/")); });
tsconfig.json
"compilerOptions": { "target": "es5", "sourceMap": true, "module": "commonjs", "moduleResolution": "node", "isolatedModules": false, "jsx": "react", "experimentalDecorators": true, "emitDecoratorMetadata": true, "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "preserveConstEnums": true, "suppressImplicitAnyIndexErrors": true }, "filesGlob": [ "**/*.ts", "**/*.tsx", "!node_modules/**", "!typings/browser/**" ]
我不太確定問題出在哪里,但是最后刪除node_modules和npm install解決了問題。 也許我在實驗時銷毀了node_modules中的一些文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.