I have this in my single Javascript client.js that I am going to run with node. It's just the single file; was not created as a node project. (no npm init):
const { WsProvider, ApiPromise } = require('@polkadot/api');
const { ContractPromise } = require('@polkadot/api-contract');
When I attemp to run it, I get (just a sample of a long list):
@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
cjs 10.1.1 node_modules/@polkadot/api/node_modules/@polkadot/util/cjs
cjs 10.1.2 node_modules/@polkadot/api-contract/node_modules/@polkadot/util/cjs
@polkadot/types has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
cjs 8.14.1 node_modules/@polkadot/api/node_modules/@polkadot/types/cjs
cjs 9.0.1 node_modules/@polkadot/api-contract/node_modules/@polkadot/types/cjs
I originally installed all npm packages "globally" ($HOME/.nvm/versions/node/blahblah...) because I didn't want a bunch of repeated node_modules all over the place.
And I did a symbolic link from the (above) global location to wherever my client.js was.
I also didn't want to have to mess with package.json etc.. just keep things as simple as possible. One file.
And it all worked until now.