I'm having issues with the wallpaper module in nodejs.
I run the install with npm, in the dir that contains my code :
npm i wallpaper -g
.
I don't have any error after that but I cannot use the module.
When I'm trying to run the script with node myprgrm.js
I get the following error : Cannot find module 'wallpaper' from '/path/' in /path/myprgrm.js
Did somone have an idea why ?
EDIT 1 :
After installing wallpaper without -g
, it created package-lock.json
, the same apply for npm i wallpaper --save
.
I get the following error :
(node:4252) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/path/myprgrm.js:1
import {getWallpaper, setWallpaper} from 'wallpaper';
^^^^^^
SyntaxError: Cannot use import statement outside a module
So I try to replace my package.json by package-lock.json but, still the same error.
And I don't really know how to preicsely manipulate .json
Thanks
Edit 2 :
I find the answer over here : SyntaxError: Cannot use import statement outside a module