Skip to content

NPM link tips

Timothy Shockley edited this page Sep 8, 2022 · 1 revision

Use wsman messages locally instead of the published library

NOTE: these directions are specific because what I saw online of simply using npm link/unlink was not working.

At the root of this project

> cd ~/open-amt-cloud-toolkit/wsman-messages

Compile the project, which will create a ./dist folder with compilation artifacts

> npm run compile

Copy in the package.json

> cp package.json dist/

Now the dist folder is ready to be referenced as a published package, so navigatge to the project referencing wsman-messages and cre

> cd ~/open-amt-cloud-toolkit/rps
> npm link ../../wsman-messages/dist/

Check that the link is working

> npm compile

This will create a global npm link to the @open-amt-cloud-toolkit/wsman-messages that you can check with the following

> npm ls --location=global

To undo the links, in the referencing projects

> npm unlink @open-amt-cloud-toolkit/wsman-messages

And to remove the global link, I think it is easiest to just delete the link shown by the ls command (this example has paths created by nvm ... node version manager)

rm -rf ~/.nvm/versions/node/v16.16.0/lib/node_modules/@open-amt-cloud-toolkit