Slightly similar to the previous thread: I have a ...
# typescript
l
Slightly similar to the previous thread: I have a code tree with my Pulumi project, shared code and test code in various subdirectories. There is a single package.json, tsconfig.json etc. in the common ancestor directory. It was working fine until I created a new project yesterday. That one project is complaining about not being able to load package.json from its own directory. Which would be fair enough, but the other project and the test directories are finding the shared package.json. What might cause Pulumi to insist on finding the file in the current directory?
Code:
Copy code
error: Error: Error reading file '/pulumi/projects/main/pulumi/projects/autostop/package.json' when computing package dependencies. Error: ENOENT: no such file or directory, open '/pulumi/projects/main/pulumi/projects/autostop/package.json'
        at readFile (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:167:19)
        at computeDependenciesDirectlyFromPackageFile (/pulumi/projects/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:150:22)
        at /pulumi/projects/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:115:36
        at /pulumi/projects/node_modules/read-package-tree/rpt.js:162:20
In case it's relevant: I'm running Pulumi from @billowy-army-68599's node-specific Pulumi image.
b
did you forget to check in your
package.json
? seems like that file isn't there
l
It's not there, deliberately. It's in /pulumi/projects, beside the
node_modules
directory.
I can run Pulumi from the other project, and run Mocha from the test directories, and they all find the correct package.json. Just this one project is set up differently somehow, and I can't see the difference.. no idea what to look for...
What influences Pulumi to look in
.
only for the file, as opposed to the normal behaviour which is to ascend the directory tree until it is found?
Oh wait I see a potentially-relevant difference.. this module is using
EventRuleEventSubscription
and has TypeScript code that gets converted to an AWS Lambda.. the other project doesn't...
Maybe
codePaths.js
is replicating the package.json-finding behaviour, but missing the rule that says "look here _or in parent directories_"....
Yep that's it. It's not using npm to load the file, it's doing it on line 115 of
codePaths.js
and the logic is only to look in the current directory and nowhere else.
b
@little-cartoon-10569 you should be able to pass -C to the cmd to have it check a different path
l
There's no command? This seems to be happening when Pulumi is compiling my inline handler parameter to aws.cloudwatch.onSchedule into a Lambda.
I'm looking in the npm code, it's using
require('path')
then
path.resolve()
for any parameter that's passed to
read-path-json
. But Pulumi is just passing
.
to the same function.
I'm trying to find the
path
module but I can't see it in npm's own package.json, and I don't know enough about JS to find it...
If I can find the solution I can raise an issue.
Found
path.resolve()
, that's not the issue... still looking...