Skip to content

Nodejs npm package management explanation #5447

@cveld

Description

@cveld

Type of issue

Missing information

Description

Can you add a paragraph on nodejs npm package management? And what this additional RestoreNpm target is all about? What does this DesignTimeBuild flag do?

Is there anything on the road to provide an integrated npm install experience? Now it is just always calling it as an external tool during the build I guess of the host. Maybe it is better to do dependency management as part of the local run experience. I guess npm install should be skipped whenever possible. There are also other package managers such as yarn and pnpm.

<Target Name="RestoreNpm" BeforeTargets="Build" Condition=" '$(DesignTimeBuild)' != 'true' ">
    <ItemGroup>
      <PackageJsons Include="..\*\package.json" />
    </ItemGroup>

    <!-- Install npm packages if node_modules is missing -->
    <Message Importance="Normal" Text="Installing npm packages for %(PackageJsons.RelativeDir)" Condition="!Exists('%(PackageJsons.RootDir)%(PackageJsons.Directory)/node_modules')" />
    <Exec Command="npm install" WorkingDirectory="%(PackageJsons.RootDir)%(PackageJsons.Directory)" Condition="!Exists('%(PackageJsons.RootDir)%(PackageJsons.Directory)/node_modules')" />
  </Target>

Page URL

https://learn.microsoft.com/en-us/dotnet/aspire/get-started/build-aspire-apps-with-nodejs

Content source URL

https://github.com/dotnet/docs-aspire/blob/main/docs/get-started/build-aspire-apps-with-nodejs.md

Document Version Independent Id

325c73ab-5567-9320-3dc7-346fb7deeecf

Platform Id

3f7a8c74-b355-e5ef-99be-54eedbd1eaf6

Article author

@IEvangelist

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions