It seems that npm install --prefix ./server (with no args) is not working with --prefix flag. I just want to install all packages from package.json.
All I get after that command is:
npm WARN enoent ENOENT: no such file or directory, open '/home/.../ProjectName/server/package.json'
All is fine when I put npm install package_name -S --prefix ./server for example. Then NPM will create node_modules in server and will add package_name package.
My files structure is:
ProjectName
|
+-- client
|   +-- node_modules
|   +-- package.json
+-- server
|   +-- node_modules
+-- package.json
"Main" package.json contains all scripts (for Heroku and for me) and dependiencies for server. 
client is Angular2 app that's why it has own node_modules and package.json.
I use NPM 4.2.0. With version 5.0.3 (newest?) it seems that --prefix flag is not working at all.
EDIT #1
I've just discovered that I can solve my problem with npm install (which will install node_modules in my project folder) and then copy node_modules to server/node_modules. Without that copy jasmine throws errors during tsc build.
Now I have to have node_modules in main catalog and copy of them in server. That's so odd..
EDIT #2
According to @Damian Lattenero answer:
npm --prefix ./server install ./ProjectName/package.json
or
npm --prefix ProjectName/server install ./ProjectName/package.json
IS NOT WORKING and generates:
npm ERR! code ENOLOCAL npm ERR! Could not install "RecursiveNotebook3/package.json" as it is not a directory and is not a file with a name ending in .tgz, .tar.gz or .tar
THIS WORKS:
npm --prefix ProjectName/server install ./ProjectName
but generates:
npm WARN saveError ENOENT: no such file or directory, open '/home/tb/Projects/RecursiveNotebook3/server/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 '/home/ tb/Projects/RecursiveNotebook3/server/package.json'
and
package-lock.json next to node_modules
and
empty etc catalog next to node_modules
and
There are some problems with build (tsc -p server) with mongodb package.
 
     
     
     
     
    