s-KaiNet / spsave

Save files in SharePoint using node.js easily
MIT License
86 stars 22 forks source link

Dev-only install causes packaging errors from SPSave #34

Closed sg-chrishasz closed 6 years ago

sg-chrishasz commented 6 years ago

Hello @s-KaiNet

Since SPGo 1.2.0, I've been using SPSave 3.1.2. It appears that there has been a change in how packages and types are linked in this version and it is now recommended to be installed as a dev dependency (npm install spsave --save-dev). Unfortunately, for SPGo that prevents spsave from being included in the production package that is deployed to the VSCode marketplace. If i try to install the package as a prod depenency (either via npm install or with the --save-prod flag) packaging will fail with a number of npm errors.

Is there a hard requirement to install spsave as a dev dependency, is there a way to install spsave without extraneous errors, or is this a PEBKAC error on my part and you have guidance you can provide on how to fix the errors below?

NPM Errors when installed or listed as a production dependency


npm ERR! extraneous: @types/mocha@2.2.41 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\@types\mocha
npm ERR! extraneous: @types/mockery@1.4.29 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\@types\mockery
npm ERR! extraneous: @types/sinon@1.16.36 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\@types\sinon
npm ERR! extraneous: chai@3.5.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\chai
npm ERR! extraneous: console.table@0.7.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\console.table
npm ERR! extraneous: coveralls@2.13.1 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\coveralls
npm ERR! extraneous: del@2.2.2 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\del
npm ERR! extraneous: gulp@3.9.1 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp
npm ERR! extraneous: gulp-debug@2.1.2 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-debug
npm ERR! extraneous: gulp-istanbul@0.10.4 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-istanbul
npm ERR! extraneous: gulp-load-plugins@1.5.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-load-plugins
npm ERR! extraneous: gulp-mocha@2.2.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-mocha
npm ERR! extraneous: gulp-plumber@1.1.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-plumber
npm ERR! extraneous: gulp-sourcemaps@2.6.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-sourcemaps
npm ERR! extraneous: gulp-tslint@5.0.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-tslint
npm ERR! extraneous: gulp-typescript@3.1.7 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\gulp-typescript
npm ERR! extraneous: map-stream@0.0.6 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\map-stream
npm ERR! extraneous: mocha-junit-reporter@1.13.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\mocha-junit-reporter
npm ERR! extraneous: mockery@1.7.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\mockery
npm ERR! extraneous: remap-istanbul@0.6.4 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\remap-istanbul
npm ERR! extraneous: run-sequence@1.2.2 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\run-sequence
npm ERR! extraneous: sinon@1.17.7 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\sinon
npm ERR! extraneous: tslint@3.15.1 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\tslint
npm ERR! extraneous: typings@1.5.0 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\typings
npm ERR! extraneous: yargs@4.8.1 C:\Users\chris\Projects\spgo\node_modules\spsave\node_modules\yargs```

Thanks, again, for all of your help to date!

-Chris
s-KaiNet commented 6 years ago

Hi Chris,
TBH I don't understand the issue clearly. When you add spsave as dependency, npm install spsave --save, you see above errors? I tried to do that and didn't receive any errors.
Also I've tried to clone spgo, run npm install, then npm install spsave --save-prod, npm said that "notice save spsave is being moved from devDependencies to dependencies" - without issues.
Have you tried deleting node_modules and do the same steps as I did?

koltyakov commented 6 years ago

Hi Chris,

Did you try deliting node_modules/folder, probably package-lock.json too, and reinstalling?

I have latest spsave as a dependency, packaged in one of the libraries, just updated it yesterday, and it worked too. Yet, in my case I use yarn.

koltyakov commented 6 years ago

Ooops had issues sending message from the phone, while was sending there was comment from Sergei. :)

s-KaiNet commented 6 years ago

Offtopic Can't believe that: 123

koltyakov commented 6 years ago

No worries, I’m a time traveler who came back for a second before your response. :)))

UPD: I have a punch for a not asked question. "It took GitHub API 2 seconds to post those commend of mine."

sg-chrishasz commented 6 years ago

Hello Everyone! Yes, I see the errors when i add SPSave as a dependency to SPGo using npm install, then npm install spsave --save or npm install spsave --save-prod. Can you try the following repro steps and let me know what you see?

Download SPGo, from 1.2.2 branch. git clone https://github.com/readysitego/spgo git checkout 1.2.2 git pull Build Project npm install npm install spsave --save-prod (optional) vsce package (you may need npm install -g vsce if the VSCode command line is not installed)

You can also replicate the issue, after npm install by using the following command npm list --production --parseable --depth=9999

You should the the errors output in my original issue report. I have found that i can successfully package SPGo if I install spsave as a dev dependencay, but then it the .visx package does not contain spsave, which is the issue with the current build on the marketplace.

It is quite possible this is an NPM issue, or something related to how packages are resolving generally, but I am only seeing these messages for spsave.

Feel free to reach out directly (chris@sitego.co) if you have specific questions. Thanks for your support! -Chris

s-KaiNet commented 6 years ago

Now I see the issue... will take a look.

s-KaiNet commented 6 years ago

So... it looks really bad. For some reason npm doesn't dedupe dependencies automatically for spsave (and only for spsave). Meaning that if you do npm install spsave in empty folder, it generates below folder structure:
node_modules -> spsave -> node_modules -> [a lot of folders]

instead should be: node_modules -> [a lot of folders, including spsave folder]

The issue is valid for npm 5.6.0 and it looks like for 5.5.1 as well. I found the issue in npm - npm install doesn't flatten (dedupe) all (transitive) dependencies, however not sure how to move forward.

s-KaiNet commented 6 years ago

@sg-chrishasz finally resolved in 3.1.4 with help of @koltyakov :)

sg-chrishasz commented 6 years ago

Thank you both for your help here! I've published an updated build of SPGo and all appears well.

s-KaiNet commented 6 years ago

Glad to hear! It appeared that npm-shrinkwrap.json caused the issue, which "locks" dependencies under spsave/node_modules. I've added it to .npmignore file, so in future you shouldn't see such kind of errors anymore.