简体   繁体   中英

how to get path for import of javascript from file

I have a file where i defined the absolute path of directory.

Ex : script=/absolutepath/scripts
utility=/absolutepath/utility

I want to use "script"/"utility" instead of absolute path in other javascript files.How i can do this.

What i want :

import random from "script/random.js"

instead of

import random from "/absolutepath/scripts/random.js"

PS :I am using k6 load generating framework which doesn't support node modules.

You currently can't do that in k6 v0.26.0.

Import paths like that are reserved for internal k6 modules (eg k6/http ) and "magic" remote import URLs (eg import from github.com/loadimpact/k6/samples/thresholds_readme_example.js instead of https://raw.githubusercontent.com/loadimpact/k6/master/samples/thresholds_readme_example.js , and we're trying to softly discourage this). You can't define your own, you either have to use relative paths or absolute paths when importing your own JS files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM