For some reason related to the tools I'm using I can't use .npmrc file. There is another way to pass configuration to npm?
Related
I'm using a scoped package in my application, some modules from it are stored on GitHub packages and the rest are in npm registry. Till now I was using only one module that is stored on GitHub, but now I need to install another one stored on npm.
Currently my .npmrc file looks like this:
registry=https://registry.npmjs.org/
#custompackage:registry=https://npm.pkg.github.com/
I want to inform npm to install specific scoped module from npm registry and keep installing others from GitHub packages. Updating .npmrc like this doesn't work (it continues looking the subpackage on GitHub):
registry=https://registry.npmjs.org/
#custompackage:registry=https://npm.pkg.github.com/
#custompackage/module1:registry=https://registry.npmjs.org/
Is it possible at all to configure .npmrc to get a part of scoped package modules from npm and the rest from GitHub pages?
i have created a project using npm init and i created a .npmrc file with some config. when i check the npm config list i am getting project config and userconfig.
do i need to remove the userconfig , but i am not able to edit the file.
i am not understanding why we need the .npmrc file , when you hit a command npm install express , all the config is done in the npm config file ?
how to edit the .npmrc global file in ubuntu ?
do we need to remove the userconfig if we need to use project config ? or its something like which ever comes it takes that
By Searching , i found some infos
when you install npm you have a global config file, whenever you need to access the global config file you can just add -g command
example : npm config list -g
for every projects you can create a .npmrc file, in that file you can configure and you will have private kind of stuff like the packages which are hosted private
so for that you need to create a .npmrc file , if you check npm config list you will have both configs (.npmrc in project folder) and (.npmrc in global)
so its like first it will check with the config in the project folder, if there is no config for project folder it will check for the global config(userconfig)
no need to remove the global config , it will take first comes first serve so the project folder config will be taken if its there otherwise only it will check for the global config
Editing the Global config file
you can edit the global config file by going to
cd /
cd home/"username"/
vi .npmrc
change the file save it by using press esc type :x
The docs explain how to control which files are not sent to the npm registry when you run npm publish.
If you use .npmignore, or you're not using git that set of files differs from the set that are pushed to your source repo.
Is there a way to list the files that npm publish will send?
I know that npm pack will create a tarball that contains those files, but creating a tarball and then listing its contents seems a little clunky.
Currently, there's no such thing in npm (see this issue).
At the moment you can use some external tools that implement the functionality you're asking for, e.g. pkgfiles or irish-pub.
As of at least npm#6, you can run npm publish --dry-run to see what files are included in your package.
https://docs.npmjs.com/cli/v6/commands/npm-publish
We have a scoped module, and for npm to be be able to resolve it, we have to say where its repo is. This can be done in i.e. .npmrc, such as:
#my-scope:registry=http://my-sweet-replication.example.com/npm/
My problem is that because of some proxying and authentication for GET requests, I have to put different values in .npmrc for development versus the build server (travis enterprise). We already take advantage of the fact that npm can read environment variables for packages that are not scoped, but as both # and : are invalid characters in an environment variable I'm unable to export the correct URL.
Any ideas on how to tell npm where to look for scoped modules without putting it in .npmrc?
For now, my solution is to use the env command, i.e. (in .travis.yml)
install: env 'NPM_CONFIG_#MY-SCOPE:REGISTRY=http://my-sweet-replication.example.com/npm/' npm install
Is that the only way to do it?
Putting it in the travis env matrix does not work, as it uses EXPORT, so it tries to export just REGISTRY
(Posting my answer as I didn't get any hits from googling)
Create the user by hand, by installing a ~/.npmrc with the appropriate token.
First, go into your project's envvars, and set the token under some name. For this example I use NPM_TOKEN, but that's not important. Some unices break with lowercase envvars, so use allcaps.
Next add the following to your .travis.yml:
before_install:
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
Now you should have an NPM user with the appropriate credentials.
I am hoping to run npm config to set values in a project's .npmrc file.
Docs dont seem to say how to specify a file to save the values into.
Looking for something like
npm config --file /path/to/repo/.npmrc set key value
Trying to use it for a build script that needs to build a .npmrc file from env vars.
It is baffling that this is seemingly still not directly supported as of npm v6.9.0.
It's a bit awkward, but if your npm version is recent enough, you can repurpose the --userconfig option to make npm config operate on a project-specific .npmrc file.
E.g., from a given project's root folder, the following command project-locally configures pwsh (PowerShell Core) as the shell to run scripts with, by making npm config operate on the local .npmrc file via --userconfig:
# Updates .npmrc in current dir
npm config set script-shell pwsh --userconfig .npmrc
Note: As Kerry Johnson points out:
The target file is rewritten as a whole, in the course of which any comments (#-prefixed lines) in the original file are lost (but all key-value pairs are preserved).
The config keyword is optional in this case, so the following will do:
npm set script-shell pwsh --userconfig .npmrc
You can do a chroot, build your config file on ~/.npmrc and then copy it on the right location.
you can override any property which could be set by the .npmrc
by passing it through command line.
For example --package-lock false will turn off package-lock generation.