You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run a local script to build an .ipa I consistently get the following error in Metro Packager console:
jest-haste-map: Haste module naming collision: react-native
The following files share their name; please adjust your hasteImpl:
* <rootDir>/node_modules/react-native/package.json
* <rootDir>/ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json
I have tried doing an rm -rf ios/build but I continue to get the above error.
node_modules/react-native-immediate-phone-call/android/build.gradle AND
node_modules/react-native-swipe-view/android/build.gradle
change compileSdkVersion to 28
change targetSdkVersion to 27
Run npx jetify && npm run build
It will prompt you for codesigning password, just give it the password to get into your machine.
Describe what you expected to happen:
The script executed with npm run build should successfully create an apk that gets stored inside of Dist/ folder, but the .ipa is not generated because of the above error.
@Frindecent , I have found that package.json is being required in 521 files, but I will guess I should remove it from the scripts that is attempting to generate the apks and ipas.
You donot need to remove package.json from the dependencies or packages.. lets say ‘react-native-vector-icons’.
Just remove the import of package.json from the original code you wrote for your app. You might be importing it for app version or maybe app name
import path from "path";
import { execSync } from "child_process";
import { name, iosDirectory } from "../../app.json";
// import { version } from "../../package.json";
// importing package.json ^^^
import { resolveFromRoot, distDir, createLogger } from "../build";
const getProcessOptions = () => {
return {
env: Object.assign({}, process.env, {
// used to skip packager, since we default to release bundler is built in
RCT_NO_LAUNCH_PACKAGER: true,
CI_IOS_VERSION_NAME: version
// CI_IOS_BUILD_NUMBER: build,
})
};
};
scripts/build.js:
import yargs from "yargs";
import path from "path";
import fs from "fs-extra";
import { version } from "../package.json";
export const buildArgv = yargs.options({
version: { string: true, default: version }
// build: { number: true, demandOption: 'build number must be passed' },
});
export const resolveFromRoot = (pathStr: string) =>
path.resolve(__dirname, `../${pathStr}`);
export const distDir = resolveFromRoot("dist");
const makeDirIfNotExists = dir => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
};
I could not comment it out from the last one because it would error out.
Results:
Still getting in Metro Packager:
jest-haste-map: Haste module naming collision: react-native
The following files share their name; please adjust your hasteImpl:
* <rootDir>/node_modules/react-native/package.json
* <rootDir>/ios/build/Build/Intermediates.noindex/ArchiveIntermediates/DEV/InstallationBuildProductsLocation/Applications/DEV.app/assets/node_modules/react-native/package.json
You will need to comment it out from the last one too.. check what is the version in package.json.. and then after commenting write
Const version = “whatever the version is” . So you wont have errors.. and next time while changing the version of the app you will change from here too
@Frindecent , I did the following refactor to scripts/build.js:
import yargs from "yargs";
import path from "path";
import fs from "fs-extra";
// import { version } from "../package.json";
const version = "4.0.0";
export const buildArgv = yargs.options({
version: { string: true, default: version }
// build: { number: true, demandOption: 'build number must be passed' },
});
export const resolveFromRoot = (pathStr: string) =>
path.resolve(__dirname, `../${pathStr}`);
export const distDir = resolveFromRoot("dist");
const makeDirIfNotExists = dir => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
};
export const makeFolderPath = dirPath => {
const pathParts = dirPath.split("/").reduce((acc, curr) => {
const newPath = path.join(acc, curr);
makeDirIfNotExists(newPath);
return newPath;
}, resolveFromRoot("."));
};
const repeatString = (input, length) => {
return Array.from({ length })
.map(_ => input)
.join("");
};
export const createSectionHeader = (
input,
{ repeatChar = "*", maxLen = 80 } = {}
) => {
if (input.length >= maxLen) {
return input;
}
// added 2 for spaces around input
const paddingNeeded = maxLen - (input.length + 2);
const padding = repeatString(repeatChar, Math.floor(paddingNeeded / 2));
return [padding, input, padding].join(" ");
};
// todo: make this better, pass logType and curry
export const logAndWriteLine = (logger, input) => {
console.log(input);
logger.write(`${input}\n`);
};
export const createLogger = args => {
let id = args;
if (typeof id === "object") {
id = args.id;
}
makeFolderPath("./dist/log");
const buildLogPath = resolveFromRoot(`dist/log/build-${id}.log`);
// use same file name and delete before opening stream
if (fs.existsSync(buildLogPath)) {
fs.removeSync(buildLogPath);
}
const stream = fs.createWriteStream(buildLogPath);
return {
logHeader: (input, { repeatChar, maxLen } = {}) => {
const header = createSectionHeader(input, { repeatChar, maxLen });
console.log(header);
// error below
stream.write(`${header}\n`);
},
write: input => stream.write(input),
log: input => console.log(input),
error: input => {
stream.write(input.message ? input.message : input);
console.error(input);
},
close: () => stream.close()
};
};
I still get the following error when running npm run android:
jest-haste-map: Haste module naming collision: react-native
The following files share their name; please adjust your hasteImpl:
* <rootDir>/node_modules/react-native/package.json
* <rootDir>/ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json
Failed to construct transformer: { Error: Duplicated files or mocks. Please check the console for more info
at setModule (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:620:17)
at workerReply (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:691:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
mockPath1: 'node_modules/react-native/package.json',
mockPath2:
'ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json' }
error Duplicated files or mocks. Please check the console for more info. Run CLI with --verbose flag for more details.
Error: Duplicated files or mocks. Please check the console for more info
at setModule (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:620:17)
at workerReply (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:691:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
The only way I am able to get the scripts working is by running:
rm -rf ios/build && GitVersion_BranchName="release/abcd" npm run build, so I have to remove ios/build directory first.
To be clear this does not resolve it, it eventually creates the /ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json this all over again.
The way I had to resolve this was by first running rm /ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
Activity
Frindecent commentedon Sep 10, 2019
you might be importing package.json in your js code. Remove that import and then try to start your bundler again.
ldco2016 commentedon Sep 10, 2019
@Frindecent , I have found that
package.jsonis being required in 521 files, but I will guess I should remove it from the scripts that is attempting to generate the apks and ipas.Frindecent commentedon Sep 10, 2019
You donot need to remove package.json from the dependencies or packages.. lets say ‘react-native-vector-icons’.
Just remove the import of package.json from the original code you wrote for your app. You might be importing it for app version or maybe app name
ldco2016 commentedon Sep 10, 2019
@Frindecent , the only place where I saw in our own code that
package.jsonis being imported is:e2e/init.js:scripts/ios/build.js:scripts/build.js:I could not comment it out from the last one because it would error out.
Results:
Still getting in Metro Packager:
Frindecent commentedon Sep 10, 2019
You will need to comment it out from the last one too.. check what is the version in package.json.. and then after commenting write
Const version = “whatever the version is” . So you wont have errors.. and next time while changing the version of the app you will change from here too
ldco2016 commentedon Sep 11, 2019
@Frindecent , I did the following refactor to
scripts/build.js:I still get the following error when running
npm run android:The only way I am able to get the scripts working is by running:
rm -rf ios/build && GitVersion_BranchName="release/abcd" npm run build, so I have to removeios/builddirectory first.To be clear this does not resolve it, it eventually creates the
/ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.jsonthis all over again.ldco2016 commentedon Sep 17, 2019
The way I had to resolve this was by first running
rm /ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.jsonstale commentedon Dec 16, 2019
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
stale commentedon Dec 23, 2019
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.