Can't add internal package (Error: 404 Not Found) using latest Lerna (v3.16.4)
I can't add internal package using these commands (I tried all of them). I issue these commands in the root of monorepo. Yarn version is 1.17.3:
lerna add [email protected] --scope=web-server --no-bootstrap
lerna add [email protected] --scope=web-serve
lerna add [email protected] --scope=web-server --exact
lerna add packages/accounting-logic --scope=web-server --exact
lerna add accounting-logic --scope=web-server --exact
My repository has all packages in packages directory.
The packages/accounting-logic has this package.json:
{
"name": "domain",
"version": "0.0.0",
"private": true,
"description": "",
"author": "",
"homepage": "",
"license": "ISC",
"scripts": {
"test": "NODE_LOG_LEVEL=fatal NODE_ENV=test mocha --opts mocha.opts ./src/**/*-test.ts",
"lint": "tslint -p tsconfig.json -c tslint.json",
"check": "yarn run lint && yarn run test"
},
"workspaces": {
"nohoist": [
"jsdom",
"ws",
"@types/node",
"@types/jsdom"
]
},
"dependencies": {
"@types/node": "11.13.5",
"currency.js": "1.2.2"
},
"devDependencies": {
"mocha": "5.2.0",
"ts-node": "8.1.0"
}
}
The packages/web-server package.json is much longer but I assure you it has its private:true property and workspaces looks like this:
"workspaces": {
"nohoist": [
"**"
]
},
Expected Behavior
I should be able to add link to the accounting-logic
Current Behavior
lerna notice cli v3.16.4
lerna ERR! Error: 404 Not Found - GET https://registry.npmjs.org/accounting-logic - Not found
lerna ERR! at res.buffer.catch.then.body (/home/user/workspace/project/node_modules/@evocateur/npm-registry-fetch/check-response.js:104:15)
lerna ERR! lerna 404 Not Found - GET https://registry.npmjs.org/accounting-logic - Not found
lerna.json
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.0"
}
lerna-debug.log
0 silly argv { _: [ 'add' ],
0 silly argv scope: 'web-server',
0 silly argv exact: true,
0 silly argv E: true,
0 silly argv globs: [],
0 silly argv lernaVersion: '3.16.4',
0 silly argv '$0': '/home/user/workspace/project/node_modules/.bin/lerna',
0 silly argv pkg: 'accounting-logic' }
1 notice cli v3.16.4
2 verbose rootPath /home/user/workspace/project
3 error Error: 404 Not Found - GET https://registry.npmjs.org/accounting-logic - Not found
3 error at res.buffer.catch.then.body (/home/user/workspace/project/node_modules/@evocateur/npm-registry-fetch/check-response.js:104:15)
Context
I can't proceed with development, I can't make accounting-logic package a dependency for web-server package.
Your Environment
Linux Ubuntu 18.04
| Executable | Version |
|---|---|
lerna --version |
v3.16.4 |
npm --version |
n/a |
yarn --version |
1.17.3 |
node --version |
v10.16.2 |
| OS | Version |
|---|---|
| Ubuntu | 18.04 |
Soooo... The problem was that package.json of accounting-logic had bad value in "name" field. It should be equal to the name of the directory (which is accounting-logic). IMHO this is the flaw in Lerna. This tool should analyze configuration and propose the correction. The error which appeared on the screen didn't say exactly what was wrong (the missing package in npmjs registry was not the true error from the point of user). So if I could propose some good behavior for Lerna, to make user experience better, Lerna should compare "name" fileds and directory names, and if they are not equal, prompt user for correction.
I faced in same problem when mistakenly try to run npm i in packet directory instead of lerna root...
@gitowiec Thanks!
@gitowiec Thanks 🙏
I had the same problem but in my case, I forgot to add the new folder in the workspaces. Could help someone :)
i.e.
"workspaces": { "packages": [ "packages/**" ] },