I am trying to add type definitions to this existing npm package: https://github.com/linchCN/react-native-swisseph
My forked repo and working branch (named typescript support) are here: https://github.com/sstephans/react-native-swisseph/tree/typescript-support
The problem I'm running into is that when I run npm pack and then install that local tarball into a project, it only shows 3 files:
index.js
package.json
README.md
However, when I run npx npm-packlist it shows me this:
index.js
package.json
README.md
index.d.ts
If I remove the "files" field in package.json entirely, it puts all the files into the tarball, but still only the same 3 as above are available in the package under node_modules.
For ease, here are what seem to be the relevant files
package.json
{
"name": "react-native-swisseph",
"version": "0.1.0",
"description": "Swiss Ephemeris binding for react-native",
"main": "index.js",
"types": "./index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": ["./index.d.ts"],
"keywords": [
"react-native",
"swiss",
"ephemeris",
"astrology",
"astronomy"
],
"author": "linch <369955292@qq.com>",
"license": "MIT",
"homepage" : "https://github.com/linchenhuicn/react-native-swisseph/",
"bugs": {
"url": "https://github.com/linchenhuicn/react-native-swisseph/issues"
},
"peerDependencies": {
"react-native": "^0.41.2"
}
}
**.npmignore
#################
# from .gitignore:
################
############
# Node
############
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
################
# JetBrains
################
.idea
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
./logo.png
############
# iOS
############
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
ios/build/
ios/DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
ios/xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
ios/Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/screenshots
############
# Android
############
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
android/bin/
android/gen/
android/out/
android/app/build/
# Gradle files
android/.gradle/
android/build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
android/proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
android/.navigation/
# Android Studio captures folder
android/captures/
# Intellij
*.iml
# Keystore files
*.jks
##################
# React-Native
##################
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# Android/IJ
#
.idea
.gradle
local.properties
# node.js
#
node_modules/
npm-debug.log
# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
Update
I've discovered what's causing the issue, but I can't figure out the fix. Basically, the tarball is being cached somewhere so no matter what the contents are actually updating to, the project that installs the tarball with package.json is using the original cached one.
The new problem: I cannot find where it is caching this tarball to delete it.
Steps Taken:
- Uninstall the local tarball dependency from test project.
- Delete actual tarball from local location.
- Empty recycle bin.
- Run
npm cache clean --forcefrom elevated command prompt - Run
npm cache verify, shows 0 indexes.
Now here's where things get screwy. So as stated above, I deleted the source tarball entirely from it's location as referenced by the test project's package.json. BUT, if I add that dependency back in, with the location where the tarball no longer exists, and run yarn install, it still installs successfully.
Conclusion: it's still cached somewhere. But where??
Hacky Solution
For the time being I have resorted to changing the version every time I run npm pack and that does force it to use the new tarball instead of the one in the mysterio cache. This is annoying and just asking for trouble when pushing things up the pipeline for pull prequests.
Ultimately, now, I hope someone will be able to answer where this secret cache is located and how I can clear it without having to trick the project with new file names or version numbers.