Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

pack command missing package-lock.json #50

Closed
LeonardMeyer opened this issue Jul 16, 2018 · 15 comments
Closed

pack command missing package-lock.json #50

LeonardMeyer opened this issue Jul 16, 2018 · 15 comments

Comments

@LeonardMeyer
Copy link

LeonardMeyer commented Jul 16, 2018

Environment

Linux Mint 18.3
Kernel 4.17.4
Node 8.11.3 (also tried 10.x)
NPM 5.10.0
oclif-dev 1.15.4

Problem

Whenever I execute oclif-dev pack (with npx or local) I get

oclif-dev: gathering workspace for xxxx to xxxx/xxxx/cli/tmp/xxxx
npm notice package-lock.json has been renamed to npm-shrinkwrap.json. npm-shrinkwrap.json will be used for future installations.
npm notice 
npm notice 📦  cli@0.1.0
npm notice === Tarball Contents === 
npm notice 1.7kB   package.json           
npm notice 160.5kB npm-shrinkwrap.json    
npm notice 465B    oclif.manifest.json    
npm notice 1.4kB   README.md              
npm notice 132B    bin/run                
npm notice 31B     bin/run.cmd            
npm notice 455B    lib/commands/hello.d.ts
npm notice 931B    lib/commands/hello.js  
npm notice 38B     lib/index.d.ts         
npm notice 149B    lib/index.js           
npm notice === Tarball Details === 
npm notice name:          cli                                     
npm notice version:       0.1.0                                   
npm notice filename:      cli-0.1.0.tgz                           
npm notice package size:  32.9 kB                                 
npm notice unpacked size: 165.8 kB                                
npm notice shasum:        f5b327aa89eccf11712b2cdd539e13486b64c1f3
npm notice integrity:     sha512-fP9Jtbex1K7gY[...]MdBfPGci/8ERA==
npm notice total files:   10                                      
npm notice 
Error: ENOENT: no such file or directory, lstat '/xxxx/xxxx/cli/package-lock.json'
zsh: command not found: oclif-dev

Of course I have a package-lock.json at the root of the cli directory prior to executing the command, but pack just deletes it and complains it's missing after.

@chrisrsipes
Copy link

I'm experiencing this issue as well. I tried setting the unchangeable flag on the package-lock.json file to see if that'd fix the issue, but it seems the package-lock.json is being renamed npm-shrinkwrap.json, which fails with the unchangeable flag.

crs$ chflags uchg package-lock.json 
crs$ oclif-dev pack
oclif-dev: gathering workspace for reflection-installer to /Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/tmp/reflection-installer
npm ERR! path /Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/package-lock.json
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/package-lock.json' -> '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/npm-shrinkwrap.json'
npm ERR!  { Error: EPERM: operation not permitted, rename '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/package-lock.json' -> '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/npm-shrinkwrap.json'
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/package-lock.json\' -> \'/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/npm-shrinkwrap.json\'',
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/package-lock.json',
npm ERR!   dest: '/Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/npm-shrinkwrap.json' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chris.sipes/.npm/_logs/2018-07-16T14_18_16_636Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! reflection-installer@0.0.0 prepack: `rm -rf lib && tsc && oclif-dev manifest && oclif-dev readme && npm shrinkwrap`
npm ERR! Exit status 255
npm ERR! 
npm ERR! Failed at the reflection-installer@0.0.0 prepack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chris.sipes/.npm/_logs/2018-07-16T14_18_16_668Z-debug.log
Error: Command failed: npm pack --unsafe-perm
null
> reflection-installer@0.0.0 prepare /Users/chris.sipes/Developer/reflection-enterprise/reflection-installer
> rm -rf lib && tsc
> reflection-installer@0.0.0 prepack /Users/chris.sipes/Developer/reflection-enterprise/reflection-installer
> rm -rf lib && tsc && oclif-dev manifest && oclif-dev readme && npm shrinkwrap
wrote manifest to /Users/chris.sipes/Developer/reflection-enterprise/reflection-installer/.oclif.manifest.json
    at makeError (/usr/local/lib/node_modules/@oclif/dev-cli/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/usr/local/lib/node_modules/@oclif/dev-cli/node_modules/execa/index.js:277:16)
    at <anonymous>

@bchatard
Copy link

Hello,

This issue is du to prepack script (in package.json), there is this command: npm shrinkwrap which rename package-lock.json to npm-shrinkwrap.json.

A quick workaround is to restore package-lock.json after npm shrinkwrap:

...
"prepack": "rm -rf lib && tsc && oclif-dev manifest && oclif-dev readme && npm shrinkwrap && git checkout -- package-lock.json",
...

@jdx
Copy link
Contributor

jdx commented Jul 25, 2018

npm should use the shrinkwrap file in place of the lockfile though, no?

@bchatard
Copy link

Yes, npm use shrinkwrap for publishing module but the pack command fail because package-lock.json is missing.

We need both files

Diff between shrinkwrap & package-lock

@dprothero
Copy link

I am getting this error as well, on Windows. Seems we shouldn't be deleting package-lock.json at all, as you want that in your git repository.

@joelgetaction
Copy link

I am getting this error as well. It is definitely oclif pack that is deleting this file (through one of its dependencies). Is there an ETA on a fix? :-)

jdx added a commit to oclif/oclif that referenced this issue Oct 13, 2018
@jdx jdx closed this as completed Oct 13, 2018
jdx added a commit that referenced this issue Oct 13, 2018
@oclif-bot
Copy link
Contributor

🎉 This issue has been resolved in version 1.19.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@joelgetaction
Copy link

Thanks for making this release. But it does not seem to fix the problem.

bash> npm list @oclif/dev-cli
RumbleSeatLiveCLI@0.0.1 /Users/joel/src/getaction/RumbleSeatLiveCLI
└── @oclif/dev-cli@1.19.1

bash> npm list -g @oclif/dev-cli
/Users/joel/.nvm/versions/node/v8.12.0/lib
├── @oclif/dev-cli@1.19.1
└─┬ RumbleSeatLiveCLI@0.0.1 -> /Users/joel/src/getaction/RumbleSeatLiveCLI
  └── @oclif/dev-cli@1.19.1

bash> oclif-dev pack --targets=linux-arm64
... normal output ...
Error: ENOENT: no such file or directory, lstat '/Users/joel/src/getaction/RumbleSeatLiveCLI/npm-shrinkwrap.json'

I even tried blowing away node_modules and resetting the npm cache. No help. It's not working because now it's deleting another file ...

So now instead of package-lock.json being erased, it's npm-shrinkwrap.json that's being erased. Any tips?

Thanks! :-)

@joelgetaction
Copy link

Well, actually the error message says Error: ENOENT: no such file or directory, lstat '/Users/joel/src/getaction/RumbleSeatLiveCLI/npm-shrinkwrap.json' but git says that the pack is still deleting package-lock.json so something is wrong with the patch to 1.19.1 ...

@jdx
Copy link
Contributor

jdx commented Oct 13, 2018

remove the bit in package.json that's deleting the shrinkwrap file and it should work after you run npm install && npm shrinkwrap

this is only required for existing CLIs

@jdx
Copy link
Contributor

jdx commented Oct 13, 2018

The issue was me not understanding that npm shrinkwrap deletes the package-lock.json so I was deleting the shrinkwrap after packing. I changed it to keep the shrinkwrap around and now it seems to work correctly.

@jdx
Copy link
Contributor

jdx commented Oct 13, 2018

package-lock.json should not be in the project, there should only be a shrinkwrap file. This way when people npm install -g your CLI it will respect the shrinkwrap.

Though dev-cli now will support either.

@NipunaPrashan
Copy link

@jdxcode do you have an answer to fix the above issue.

$ oclif-dev -v
@oclif/dev-cli/1.19.4

$ git status
deleted: package-lock.json

$ oclif-dev pack:deb
..
..
..
Error: ENOENT: no such file or directory, lstat 'xxxx/cli/npm-shrinkwrap.json'

@lordrip
Copy link

lordrip commented Nov 17, 2019

I've added
"prepack": "npm shrinkwrap && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
and did the trick

@solmon
Copy link

solmon commented May 31, 2020

I've added
"prepack": "npm shrinkwrap && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
and did the trick

Thank you @lordrip
you saved my mid night oil.. it worked as of now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants