在将本地软件包安装到另一个本地软件包时,为什么要添加node_modules?

时间:2019-10-09 12:59:53

标签: typescript package yarn

搜索此问题的答案时,我有些困惑。

我创建了一个typescript / nodejs包“ firstmodule”。建成后,DIST  文件夹仅包含几个子目录中的.js个文件和一个index.js文件

但是,当将此软件包作为依赖项添加到另一个应用程序yarn add c:\....\firstmodule时,该软件包已很好地安装在c:\...\app\node_modules\firstmodule中,但是 firstmodule的node_modules也已安装 {{ 1}}。 为什么呢这大大增加了应用程序的大小。

如何避免这种情况?查看从NPM下载的所有软件包,它们都没有安装node_modules。

我想配置文件中必须有一个选项,但是找不到哪个。

想指导我。

编辑

这是问题的屏幕截图。 我们可以看到我的本地模块“ @C *** \ g ****”已经很好地安装为依赖项。 但是,它自己的node_modules也已经存在,例如,@ appolographql模块已经安装在pmain projet中。在我看来,这是一个奇怪的问题

enter image description here

这是firsmodule的package.json:

c:\...\app\node_modules\firstmodule\node_modules\**

这是tsconfig

{
    "name": "firstmodule",
    "version": "1.0.0",
    "main": "./dist/index.js",
    "types": "./dist/index.d.ts",
    "license": "MIT",
    "author": {
        "email": "****.com",
        "name": "***"
    },
    "keywords": [
        "Api"
    ],
    "scripts": {
        "build": "tsc",
        "start": "ts-node-dev --respawn src/index.ts",
        "prebuild": "yarn lint:fix && rm -rf dist",
        "lint": "./node_modules/.bin./eslint --ext ts ./src",
        "lint:fix": "yarn lint --fix"
    },
    "devDependencies": {
        "@types/bcryptjs": "^2.4.2",
        "typescript": "^3.6.3"
    },
    "dependencies": {
        "bcryptjs": "^2.4.3",
    },
    "engines": {
        "node": ">=10"
    }
}

0 个答案:

没有答案