Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing imports #1

Closed
ngmariusz opened this issue Sep 15, 2022 · 1 comment
Closed

missing imports #1

ngmariusz opened this issue Sep 15, 2022 · 1 comment

Comments

@ngmariusz
Copy link

❯ tzx zx_scripts_plain/test.ts

node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tsup' imported from /home/md/.volta/tools/image/packages/tzx/lib/node_modules/tzx/dist/index.js
Did you mean to import tsup/lib/node_modules/tsup/dist/index.js?
    at new NodeError (node:internal/errors:387:5)
    at packageResolve (node:internal/modules/esm/resolve:951:9)
    at moduleResolve (node:internal/modules/esm/resolve:1000:20)
    at defaultResolve (node:internal/modules/esm/resolve:1214:11)
    at nextResolve (node:internal/modules/esm/loader:165:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

REPRO

❯ volta list

⚡️ Currently active tools:

Node: v16.17.0 (default)
Tool binaries available:
    tsup, tsup-node (default)
    tsc, tsserver (default)
    tzx (default)
    zx (default)

See options for more detailed reports by running volta list --help.

❯ ls /home/md/.volta/tools/image/packages/tsup/lib/node_modules

tsup


❯ ls /home/md/.volta/tools/image/packages/tsup/lib/node_modules/tsup

LICENSE README.md assets dist node_modules package.json


❯ ls /home/md/.volta/tools/image/packages/tzx/lib/node_modules/tzx/dist

index.js index.js.map

❯ cat /home/md/.volta/tools/image/packages/tzx/lib/node_modules/tzx/dist/index.js

#!/usr/bin/env node

// src/index.ts
import tsup from "tsup";
import crypto from "node:crypto";
import { $, path, fs, argv, chalk } from "zx";
var id = crypto.randomBytes(6).toString("hex");
var dir = path.resolve(process.cwd(), .tzx-${id});
var args = process.argv.slice(3);
var clean = () => {
try {
fs.rmSync(dir, { recursive: true });
} catch {
}
};
process.on("SIGINT", clean);
process.on("SIGTERM", clean);
try {
let input = argv._[0];
if (!input) {
console.log(chalk.red("\n[Error]"));
console.log(No file specified);
process.exit(1);
}
if (!input.includes("."))
input += ".tz";
const output = path.resolve(dir, input.replace(".ts", ".js"));
const outputPKG = path.resolve(dir, package.json);
const outputTSConfig = path.resolve(dir, tsconfig.json);
await $rm -rf ${dir}.quiet();
await $mkdir -p ${dir}.quiet();
await $cp ${input} ${dir}/${input}.quiet();
await fs.writeJSON(outputPKG, {
name: "tmp_script",
version: "1.0.0",
type: "module"
});
await fs.writeJSON(outputTSConfig, {});
await tsup.build({
config: false,
entry: [${dir}/${input}],
outDir: dir,
format: "esm",
target: "node16",
platform: "node",
skipNodeModulesBundle: true,
splitting: false,
silent: true,
noExternal: [/./],
outExtension: () => ({ js: ".js" })
});
const content = await fs.readFile(output, "utf8");
const updated = content.replace(/^import.
("|')zx(";|';|"|')/gm, "");
await fs.writeFile(output, updated);
try {
await $zx ${output} ${args}.pipe(process.stdout);
} catch {
}
clean();
} catch (e) {
clean();
console.error(e);
process.exit(1);
}
//# sourceMappingURL=index.js.map%



❯ ls /home/md/.volta/tools/image/packages/tzx/lib/node_modules/tzx

dist node_modules package.json readme.md src test tsconfig.json

❯ ls /home/md/.volta/tools/image/packages/tzx/lib/node_modules/tzx/node_modules

@nodelib            fetch-blob         is-glob            path-type        through
@types              fill-range         is-number          pause-stream     to-regex-range
braces              formdata-polyfill  isexe              picomatch        universalify
chalk               from               jsonfile           ps-tree          web-streams-polyfill
data-uri-to-buffer  fs-extra           map-stream         queue-microtask  which
dir-glob            glob-parent        merge2             reusify          yaml
duplexer            globby             micromatch         run-parallel     zx
event-stream        graceful-fs        minimist           slash
fast-glob           ignore             node-domexception  split
fastq               is-extglob         node-fetch         stream-combiner
@ngmariusz ngmariusz changed the title missing tsup module missing imports Sep 15, 2022
@realfresh
Copy link
Owner

just fixed in latest version - 0.1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants