I have a folder with all my projects. Every time I start a new project in a new subfolder I am installing phaser inside using npm install phaser. This results in creating new node_modules 60MB+ subfolder.
I know there is a npm flag -g when installing, but when I install phaser globally I don’t see IntelliSense hints.
Is there a way to ‘install’ the node_modules folder only once and point to it in the project instead of having it in every project subfolder?
Thank you for your answear, but it still doesn’t work.
Here are the steps I’m taking:
cd projects npm install phaser
output:
npm WARN saveError ENOENT: no such file or directory, open 'D:\projects\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\projects\package.json'
npm WARN projects No description
npm WARN projects No repository field.
npm WARN projects No README data
npm WARN projects No license field.
+ phaser@3.55.2
added 6 packages from 4 contributors and audited 6 packages in 2.317s
found 0 vulnerabilities
The projects/node_modules is created and it is ~61MB. There is also new file package-lock.json created.
Next steps: cd project_01 npm install ../node_modules/phaser
output:
npm WARN saveError ENOENT: no such file or directory, open 'D:\projects\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:\projects\package.json'
npm WARN projects No description
npm WARN projects No repository field.
npm WARN projects No README data
npm WARN projects No license field.
+ phaser@3.55.2
updated 1 package and audited 8 packages in 0.627s
found 0 vulnerabilities
now the projects/node_modules is only 97kB and the projects/node_modules/phaser directory is empty (!?)
nothing changed in the project_01 and IntelliSense is not working
It works, but the biggest disadvantage of this solution is that it creates JUNCTION link in “newproject” folder to node_modules/phaser in “projects”, and JUNCTION links are absolute not relative. So copy the projects directory to other disk will break the links
as I mentioned before, those junctions paths are absolute, so if you copy the whole projects folder to another destination, all the node_modules links are broken and IntelliSense in VSCode stops working.
Pass environment variables to webpack’s config file, and set these environment variables in a shell script for each project. i.e. Running packing tool with different setting for each project.