Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

node.js - Build Package.Json From Existing Node_Modules Folder?

I have a node_modules folder that works, and I have tried many permutations of package.json's that should create identical results and create extremely close results, but my project will not build. I have no idea how to remedy this problem.

I have matched versions using npm listand manually adding to my package.json, I have used winMerge to try to find differences.

My existing node_modules folder works, but if I rebuild it, it fails miserably. I am at wit's end.

Edit Node: 6.9.5 and NPM 4.2.0

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could try to use shrinkwrap to nail down the dependencies from your existing node_modules folder.

See https://docs.npmjs.com/cli/shrinkwrap

It should create a npm-shrinkwrap with all versions nailed to the ones currently used in the node_modules folder with npm shrinkwrap.

On the second system or in the second folder put the npm-shrinkwrap.json besides the package.json and try a npm install. In the optimal case it will recreate your modules exactly as in the existing location.

If that does not help - can you post some more detailed error outputs?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...