steep-portugal-37539
11/09/2021, 4:53 AMnpm install
a pulumi repo via a github url? I keep getting error SyntaxError: Cannot use import statement outside a module
when running pulumi in the repo that installed the pulumi package.
It seems i may need to set the “main” field in package.json to point to the compiled entrypoint .js file. However, that then messes up pulumi when i try and run it locally from the repo. As now pulumi tries to invoke the index.js file instead of the index.ts file.
I’m trying to mimic how an installed pulumi npm module works. There are .js, .js.map, and .d.ts files. No .ts files. I’m not sure how to replicate this so that the install via github url works, as well as running pulumi within the pulumi pkg repo itself (I do that for testing)
I can’t figure this out 🙂 Any advice would be much appreciatedminiature-king-36473
11/09/2021, 8:40 AMrequire
to load the program. This means that all the code which is used must use commonJs and not newer es6 modules. I suspect that the package you are trying to use has not been compiled to commonJs - do you have "compilerOptions.module": "commonjs"
set in the module you are trying to import?
When you say "import a pulumi repo via a github url", are you trying to import the source code? In which can you probably need to build a package and import that (you could use github packages for this)steep-portugal-37539
11/09/2021, 5:40 PMindex.js
, right? Otherwise pulumi won’t be able to run the installed pkg.miniature-king-36473
11/10/2021, 11:08 AMexample
folder where I have a Pulumi program which can create these resources for testing purposes.
I then install these packages into other repositories which use these components in different environments. The advantage of this approach is I can keep my components versioned and easily track updates to the environments. The downside is lots of building of packages which can be tedious at times.
If you wanted to just reference the source code, you could probably use git submodules to bring the code into the current repository. I have never really got my head around those though and always seen to end up in a mess. YMMV though.prepare
script that npm will run when you do an install
for a git url. This could run tsc
to build the code from the repository so that Pulumi can use it.steep-portugal-37539
11/10/2021, 9:07 PMminiature-king-36473
11/11/2021, 9:00 AM