I would like to publish my git repository to npm so I can use it in other projects. But when I run the npm publish command I get the following error:
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/vue-toggle-component
npm ERR! 404
npm ERR! 404 'vue-toggle-component#0.1.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\niels\AppData\Roaming\npm-cache\_logs\2020-10-29T10_47_26_952Z-debug.log
When trying to bugfix, I have tried the npm adduser command and the npm login command to make sure I logged in. Both of these did not solve my problem since it looked like I was already logged in.
My package.json:
{
"name": "vue-toggle-component",
"version": "0.1.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"description": "## Project setup ``` yarn install ```",
"main": "babel.config.js",
"repository": {
"type": "git",
"url": "git+https://github.com/nehlis/vue-toggle-component.git"
},
"keywords": [
"Vue.js",
"Toggle",
"component",
"Lightweight",
"Checkbox"
],
"author": "Niels Bosman",
"license": "ISC",
"bugs": {
"url": "https://github.com/nehlis/vue-toggle-component/issues"
},
"homepage": "https://github.com/nehlis/vue-toggle-component#readme"
}
Does anyone know how to fix this?
Try npm login. In case of npm publish, sometimes misleading message is shown.
Based on the https://npm.pkg.github.com/ appearing in the error output, you are trying to publish to GitHub Packages and not the npm registry (which are still separate, although GitHub now owns npm). According to the GitHub packages docs:
GitHub Packages only supports scoped npm packages. Scoped packages have names with the format of #owner/name. Scoped packages always begin with an # symbol. You may need to update the name in your package.json to use the scoped name. For example, "name": "#codertocat/hello-world-npm".
So you'll need to either change your configuration to point to the npm registry rather than the GitHub packages registry, or else change the name field in your package.json to be a scoped package name.
I have the same issue the problem comes from the published package is not accessible so you will need to add .npmrc with your private repo to be like this
registry=https://npm.pkg.github.com/yourcompany
or
#yourcompany:registry=https://npm.pkg.github.com
As another user mentioned you have to add yourself to the private registry of your company or organization. But if you don't have your .npmrc setup, this command will create the file automatically as well as update your registry:
npm config set registry https://registry.your-company-registry.npme.io/
However the most robust way is to simply do
npm login
It's all about authentication.
Seems like username/password auth is no more working with npm publish.
You need to generate Access Token
Then use it to publish
NPM_TOKEN=blahblahblahblaha npm publish
In the .npmrc file add the below code
always-auth = true
#your_company:registry=https://npm.artifactory.your_company.com/artifactory/api/npm/npm/
registry=https://npm.artifactory.your_company.com/artifactory/api/npm/npm/
In GIT bash execute command
npm config set registry https://registry.npmjs.org/
npm install
I faced the same problem and used almost all the valid solutions that I felt
If you published it on GitHub then this could be something that could help you.
like
updating npm to the latest version
setting registry using
npm config set registry https://registry.your-company-registry.npme.io/
resetting token
It still didn't work
If you have uppercase characters in your GitHub username, and if you are using the command provided by GitHub under the package section
Make sure to update your username when you run that command locally
By default, GitHub does not show uppercase characters in the command under the packages section.
So if your user name is UserName123 and package name is my-first-package
the command that GitHub will show is
npm install #username123/my-first-package#1.0.0
see that the username is case-sensitive when you install a package
hence, update your command to
npm install #Username123/my-first-package#1.0.0
and hopefully it should work fine
Related
I have 4 packages in my package.json:
"#CT/package-1": "*",
"#CT/package-2": "*",
"#CT/package-3": "*",
"#CT/package-4": "*",
All four packages are not on the NPM registry, but locally linked.
In each package directory I did:
sudo npm link
After that I went into my main project and linked all packages like so:
npm link #CT/package-1
npm link #CT/package-2
npm link #CT/package-3
npm link #CT/package-4
For each command it outputs the linked chain of the sym-links, I checked the paths of each one, and it's correct. If I go in the node_modules folder of my main project and follow #CT/package-X I will end up in my local package directory.
Now I expect that I can run npm i on my main project and it won't try to install those packages from the npm registry. This works for package 2-4, but it does not work for package-1:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/#CT%2fpackage-1 - npm package "package-1" does not exist under owner "CT"
As soon as I remove "#CT/package-1": "*", from my package.json, npm i will success, because it seems to right-fully skip package 2-4, just not package-1.
Now I inspected all four package projects, and it makes no sense to me. All projects compile, all package.json contain the correct package name. Here is the package.json of my first faulty package:
{
"name": "#CT/package-1",
"version": "0.0.2",
"description": "",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
"dist/"
],
"author": "martin-braun",
"license": "ISC",
"keywords": [
"capacitor",
"plugin",
"native"
],
"scripts": {
"lint": "npm run prettier -- --check",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"build": "npm run prettier && npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"#capacitor/android": "^3.0.0",
"#capacitor/core": "^3.0.0",
"#capacitor/docgen": "^0.0.18",
"#ionic/eslint-config": "^0.3.0",
"#ionic/prettier-config": "^1.0.1",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"typescript": "~4.0.3"
},
"peerDependencies": {
"#capacitor/core": "^3.0.0"
},
"prettier": "#ionic/prettier-config",
"eslintConfig": {
"extends": "#ionic/eslint-config/recommended"
},
"capacitor": {
"android": {
"src": "android"
}
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/CT"
},
"dependencies": {}
}
.npmrc
registry=https://npm.pkg.github.com/#CT
registry=https://registry.npmjs.org
When I linked the project on my main project it shew the right paths (i.e.)
/Users/mb/Projects/CT/MAIN/node_modules/#CT/package-1 -> /Users/mb/node_module_collections/ekol/lib/node_modules/#CT/package-1 -> /Users/mb/Projects/CT/package-1
What could I try to find the issue? Again, package 2-4 won't cause npm i to fail, but package.json and npmrc look similar. I'm thankful for any advice.
node v13.12.0
I looked at and executed almost every single answer on this post:
The CLI moved into a separate package: webpack-cli
It has not helped.
Allow me to present my case:
So I have developed a container folder, a separate application where I ran npm init -y and then installed the following:
npm install html-webpack-plugin#4.5.0 nodemon webpack#5.3.2 webpack-cli#4.1.0 webpack-dev-server#3.11.0
Then I went into my package.json file and added the start script:
{
"name": "container",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"html-webpack-plugin": "^4.5.0",
"nodemon": "^2.0.6",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
}
When I go to terminal and run npm start, this is why I get every single time:
➜ container npm start
> container#1.0.0 start /Users/luiscortes/Projects/ecommRS/container
> webpack serve
[webpack-cli] The command moved into a separate package: #webpack-cli/serve
? Would you like to install #webpack-cli/serve? (That will run npm install -D #webpack-cli/serve) (Y/n) › true
And yes even if I choose Y or true and it runs its npm install -D #webpack-cli/serve, when I go back to running npm start it just gives me the same error over and over again.
Apparently, this is an issue with webpack-cli#4.1.0. I upgraded to webpack-cli#4.2.0 and now it works.
I am now unable to run tests, I was able to run the basic sum.js test on jests tutorial page, but am unable to test my react code. I've seen on other sites that moving the node 4.x fixes the issue, but not for me. Any help is appreciated.
C:\wamp\www\ccRelaunchWorkspace>node -v
v4.3.0
I am running windows 7
"devDependencies": {
"babel-jest": "^9.0.0",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-react": "*",
"jest-cli": "*",
"react-addons-test-utils": "~0.14.0"
},
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "./node_modules/babel-jest",
"unmockedModulePathPatterns": [
"./node_modules/react",
"./node_modules/react-dom",
"./node_modules/react-addons-test-utils"
]
},
error:
Using Jest CLI v0.7.0
Error reading file: `C:\wamp\www\ccRelaunchWorkspace\node_modules\babel-preset-e
s2015\node_modules\babel-plugin-transform-es2015-parameters\node_modules\babel-t
raverse\node_modules\babel-code-frame\node_modules\chalk\node_modules\ansi-style
s\package.json`
C:\wamp\www\ccRelaunchWorkspace\node_modules\jest-cli\node_modules\node-haste\li
b\loader\ResourceLoader.js:88
throw err;
^
Error: EMFILE: too many open files, open 'C:\wamp\www\ccRelaunchWorkspace\node_m
odules\babel-preset-es2015\node_modules\babel-plugin-transform-es2015-parameters
\node_modules\babel-traverse\node_modules\babel-code-frame\node_modules\chalk\no
de_modules\ansi-styles\package.json'
at Error (native)
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
I have completely remove all modules, and moved all of my modules into dependencies, instead of having some in devDependencies, and removed the version numbers on anything jest related and replaces the versions with * and then ran npm install
When deploying an OpenShift node.js project with a depdency on browserify 4.0.0, I get an error installing browserify's dependencies. Specifically:
...
remote: npm ERR! Error: No compatible version found: stream-browserify#'^1.0.0'
remote: npm ERR! Valid install targets:
remote: npm ERR! ["0.0.0","0.0.1","0.0.2","0.0.3","0.0.4","0.1.0","0.1.1","0.1.2","0.1.3","1.0.0"]
...
Given that stream-browserify's version is ^1.0.0 according to browserify's depdency and that openshift is suggesting 1.0.0 is a valid install target, why is this failing? I have seen this error in other cases, whenever the highest available openshift version fits the careted package.json version.
Am I misunderstanding what the caret means? Is this an OpenShift bug?
My package.json:
{
"name": "SampleApp",
"version": "1.0.0",
"description": "do things online",
"keywords": [
"OpenShift",
"Node.js",
"application",
"openshift"
],
"author": {
"name": "J",
"email": "j#email.com",
"url": ""
},
"homepage": "http://www.openshift.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": "0.x",
"npm": "1.x"
},
"dependencies": {
"body-parser": "1.x",
"browserify": "4.0.0",
"cookie-parser": "1.x",
"cookie-session": "1.x",
"express": "4.x",
"fast-csv": "0.x",
"multer": "0.0.5",
"pg": "3.x",
"sql": "0.x",
"xlsx-extract": "0.0.4"
},
"devDependencies": {
},
"bundleDependencies": [],
"private": true,
"main": "server.js",
"scripts": {
"build-js": "browserify public/index.js -o public/index-bundle.js & browserify public/intake.js -o public/intake-bundle.js",
"start": "npm run build-js && node server.js"
}
}
This behaviour could be because of different versions on node and npm on your local machine and openshift environment. Start by fixing "engines" attribute in your package.json, something as below:
"engines": {
"node": ">= 0.10",
"npm": ">= 1.4"
}
If still the issue is there (on openshift) it is due to the unavailability of the nodejs/npm required versions on openshift environment. For example, as of today, on my local machine I may be using node version 0.10.28 and npm version 1.4.9, but on openshift nodejs default cartridge I have to be content with nodejs version 0.10.5 and npm version 1.2.17, which is a big gap.
So, in this case, the easiest way to get around is by using "npm shrinkwrap", which freezes the nested dependency versions that ought to be used, hence doing away with varied behaviour of npm versions to figure out the nested dependency to install.
Can read about shrinkwrap here: https://www.npmjs.org/doc/cli/npm-shrinkwrap.html
So, on your local machine:
run npm install and make sure everything works.
fire npm shrinkwrap This will create a file - "npm-shrinkwrap.json", with the required shrinkwrap info. Add, commit and push the file to the openshift git repo.
This is my NPM Package JSON, the Git Repository is defined in the json. It is a password protected on hosted at Kiln. But NPM still complains of a repository field missing ?
This is the error
npm WARN package.json dateformat#1.0.2-1.2.3 No repository field.
And this is the contents of my package.json
{
"name": "Pocket-to-Pocket",
"version": "1.0.0",
"description": "Card Management App For PFS",
"main": "Gruntfile.js",
"scripts": {},
"repository": {
"type": "git",
"url": "https://nyx.kilnhg.com/Code/Prepaid-Financial-Services/Group/Pocket-to-Pocket.git"
},
"author": "Nyx Digital",
"license": "All Rights Reserved.",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-imageoptim": "~1.2.12"
}
}
That warning is a dependency warning, and just means that the package dateformat for version 1.0.2-1.2.3 has no repository field. This doesn't affect your application, and it isn't an error, just a warning.
You can check this, as your application depends on Grunt, and Grunt depends on dateformat#1.0.2-1.2.3. By checking the GitHub repository, you can see that the repository field for dateformat wasn't added until after version 1.2.3. The commit is here.