admin管理员组文章数量:1024582
My goal is to download the entire dependency tree of a npm project, including production, development, optional, and peer dependencies, so I can upload them to my offline Sonatype-Nexus-Repository.
According to the npm documentation, the --include
option can enable the installation of different types of dependencies, such as optional, development, peer, and production dependencies. For example:
npm install PACKAGE_NAME --no-save --include=prod --include=dev --include=optional --include=peer
However, neither a plain npm install nor the above command successfully downloads all dependencies. For instance, let’s consider the dependencies of [email protected] as defined in its package.json:
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",
"rollup": "^4.20.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"devDependencies": {
"@ampproject/remapping": "^2.3.0",
"@babel/parser": "^7.25.6",
"@jridgewell/trace-mapping": "^0.3.25",
"sass": "^1.77.8",
"sass-embedded": "^1.77.8",
...
},
"peerDependencies": {
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
...
}
When I run the above command (npm install with --include flag
s), it only installs the dependencies and skips the devDependencies, optionalDependencies, and peerDependencies.
For example, after running:
npm install [email protected] --no-save --include=prod --include=dev --include=optional --include=peer
The output of the ls command in the node_modules folder looks like this:
@esbuild esbuild nanoid picocolors postcss @rollup rollup source-map-js @types vite
This list includes only the main dependencies, while the other types are completely ignored.
What I’m looking for:
I need a way to install ALL dependencies of an npm module, including:
dependencies
devDependencies
optionalDependencies
peerDependencies
Is there a specific npm command or a workaround that ensures all dependency types are installed together?
(Additional Information): Why do I need all packages? My goal is to upload all dependencies of a project to an offline, private npm repository (Sonatype Nexus Repository). This repository will serve as the package source, enabling me to perform npm install and retrieve all required packages directly from the private repository.
My goal is to download the entire dependency tree of a npm project, including production, development, optional, and peer dependencies, so I can upload them to my offline Sonatype-Nexus-Repository.
According to the npm documentation, the --include
option can enable the installation of different types of dependencies, such as optional, development, peer, and production dependencies. For example:
npm install PACKAGE_NAME --no-save --include=prod --include=dev --include=optional --include=peer
However, neither a plain npm install nor the above command successfully downloads all dependencies. For instance, let’s consider the dependencies of [email protected] as defined in its package.json:
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",
"rollup": "^4.20.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"devDependencies": {
"@ampproject/remapping": "^2.3.0",
"@babel/parser": "^7.25.6",
"@jridgewell/trace-mapping": "^0.3.25",
"sass": "^1.77.8",
"sass-embedded": "^1.77.8",
...
},
"peerDependencies": {
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
...
}
When I run the above command (npm install with --include flag
s), it only installs the dependencies and skips the devDependencies, optionalDependencies, and peerDependencies.
For example, after running:
npm install [email protected] --no-save --include=prod --include=dev --include=optional --include=peer
The output of the ls command in the node_modules folder looks like this:
@esbuild esbuild nanoid picocolors postcss @rollup rollup source-map-js @types vite
This list includes only the main dependencies, while the other types are completely ignored.
What I’m looking for:
I need a way to install ALL dependencies of an npm module, including:
dependencies
devDependencies
optionalDependencies
peerDependencies
Is there a specific npm command or a workaround that ensures all dependency types are installed together?
(Additional Information): Why do I need all packages? My goal is to upload all dependencies of a project to an offline, private npm repository (Sonatype Nexus Repository). This repository will serve as the package source, enabling me to perform npm install and retrieve all required packages directly from the private repository.
Share Improve this question edited Nov 29, 2024 at 15:27 thelearner asked Nov 29, 2024 at 15:13 thelearnerthelearner 1,1264 gold badges29 silver badges61 bronze badges 3- For your own repo, generally you proxy to the upstream and cache – Daniel A. White Commented Nov 29, 2024 at 15:24
- @DanielA.White Unfortunately, this isn't possible because there is no internet connectivity in the target environment. – thelearner Commented Nov 29, 2024 at 15:26
- To the people downvoting: how could I improve the question? – thelearner Commented Nov 30, 2024 at 12:29
1 Answer
Reset to default 1 +400npm install
will not download its dev dependencies, because they are supposed to be installed only when developing the package. To install all the dependencies, you should run the command from within the package.
If you need this for an arbitrary package, you can do this: get the package's package.json, put it in an empty temp directory, and run npm install
there - all the dependencies will be installed.
Here's how you can bring the package.json of a package (run it in an empty directory and it will put vite's package.json there):
curl $(npm view [email protected] | grep tarball | awk '{print$2}') | tar -x --strip-components=1 package/package.json
Now run npm install
and it will install all the dependencies.
Note: specifically for this vite example, npm install fails with:
npm ERR! Unsupported URL Type "link:": link:./src/types
To make it pass, you can edit the package.json
and just remove the two link dependencies from there.
My goal is to download the entire dependency tree of a npm project, including production, development, optional, and peer dependencies, so I can upload them to my offline Sonatype-Nexus-Repository.
According to the npm documentation, the --include
option can enable the installation of different types of dependencies, such as optional, development, peer, and production dependencies. For example:
npm install PACKAGE_NAME --no-save --include=prod --include=dev --include=optional --include=peer
However, neither a plain npm install nor the above command successfully downloads all dependencies. For instance, let’s consider the dependencies of [email protected] as defined in its package.json:
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",
"rollup": "^4.20.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"devDependencies": {
"@ampproject/remapping": "^2.3.0",
"@babel/parser": "^7.25.6",
"@jridgewell/trace-mapping": "^0.3.25",
"sass": "^1.77.8",
"sass-embedded": "^1.77.8",
...
},
"peerDependencies": {
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
...
}
When I run the above command (npm install with --include flag
s), it only installs the dependencies and skips the devDependencies, optionalDependencies, and peerDependencies.
For example, after running:
npm install [email protected] --no-save --include=prod --include=dev --include=optional --include=peer
The output of the ls command in the node_modules folder looks like this:
@esbuild esbuild nanoid picocolors postcss @rollup rollup source-map-js @types vite
This list includes only the main dependencies, while the other types are completely ignored.
What I’m looking for:
I need a way to install ALL dependencies of an npm module, including:
dependencies
devDependencies
optionalDependencies
peerDependencies
Is there a specific npm command or a workaround that ensures all dependency types are installed together?
(Additional Information): Why do I need all packages? My goal is to upload all dependencies of a project to an offline, private npm repository (Sonatype Nexus Repository). This repository will serve as the package source, enabling me to perform npm install and retrieve all required packages directly from the private repository.
My goal is to download the entire dependency tree of a npm project, including production, development, optional, and peer dependencies, so I can upload them to my offline Sonatype-Nexus-Repository.
According to the npm documentation, the --include
option can enable the installation of different types of dependencies, such as optional, development, peer, and production dependencies. For example:
npm install PACKAGE_NAME --no-save --include=prod --include=dev --include=optional --include=peer
However, neither a plain npm install nor the above command successfully downloads all dependencies. For instance, let’s consider the dependencies of [email protected] as defined in its package.json:
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",
"rollup": "^4.20.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"devDependencies": {
"@ampproject/remapping": "^2.3.0",
"@babel/parser": "^7.25.6",
"@jridgewell/trace-mapping": "^0.3.25",
"sass": "^1.77.8",
"sass-embedded": "^1.77.8",
...
},
"peerDependencies": {
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
...
}
When I run the above command (npm install with --include flag
s), it only installs the dependencies and skips the devDependencies, optionalDependencies, and peerDependencies.
For example, after running:
npm install [email protected] --no-save --include=prod --include=dev --include=optional --include=peer
The output of the ls command in the node_modules folder looks like this:
@esbuild esbuild nanoid picocolors postcss @rollup rollup source-map-js @types vite
This list includes only the main dependencies, while the other types are completely ignored.
What I’m looking for:
I need a way to install ALL dependencies of an npm module, including:
dependencies
devDependencies
optionalDependencies
peerDependencies
Is there a specific npm command or a workaround that ensures all dependency types are installed together?
(Additional Information): Why do I need all packages? My goal is to upload all dependencies of a project to an offline, private npm repository (Sonatype Nexus Repository). This repository will serve as the package source, enabling me to perform npm install and retrieve all required packages directly from the private repository.
Share Improve this question edited Nov 29, 2024 at 15:27 thelearner asked Nov 29, 2024 at 15:13 thelearnerthelearner 1,1264 gold badges29 silver badges61 bronze badges 3- For your own repo, generally you proxy to the upstream and cache – Daniel A. White Commented Nov 29, 2024 at 15:24
- @DanielA.White Unfortunately, this isn't possible because there is no internet connectivity in the target environment. – thelearner Commented Nov 29, 2024 at 15:26
- To the people downvoting: how could I improve the question? – thelearner Commented Nov 30, 2024 at 12:29
1 Answer
Reset to default 1 +400npm install
will not download its dev dependencies, because they are supposed to be installed only when developing the package. To install all the dependencies, you should run the command from within the package.
If you need this for an arbitrary package, you can do this: get the package's package.json, put it in an empty temp directory, and run npm install
there - all the dependencies will be installed.
Here's how you can bring the package.json of a package (run it in an empty directory and it will put vite's package.json there):
curl $(npm view [email protected] | grep tarball | awk '{print$2}') | tar -x --strip-components=1 package/package.json
Now run npm install
and it will install all the dependencies.
Note: specifically for this vite example, npm install fails with:
npm ERR! Unsupported URL Type "link:": link:./src/types
To make it pass, you can edit the package.json
and just remove the two link dependencies from there.
本文标签:
版权声明:本文标题:How to Install All Dependency Types (Prod, Dev, Optional, Peer) of an NPM Module? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1736210702a1393417.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论