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

npm install Error "sh: 1: source: not found" #39

Open
ms6rb opened this issue Apr 22, 2023 · 6 comments
Open

npm install Error "sh: 1: source: not found" #39

ms6rb opened this issue Apr 22, 2023 · 6 comments

Comments

@ms6rb
Copy link

ms6rb commented Apr 22, 2023

I'm trying to install the packages on fresh WSL Ubuntu

$ uname -a
Linux Ms6RB 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ npm -v
9.6.5

node -v
v19.0.0

$ go version
go version go1.20.3 linux/amd64

when I try npm install:

> [email protected] postinstall
> source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server

sh: 1: source: not found
npm ERR! code 127
npm ERR! path /home/ms6rb/vault-ai
npm ERR! command failed
npm ERR! command sh -c source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server

npm ERR! A complete log of this run can be found in: /home/ms6rb/.npm/_logs/2023-04-22T10_52_12_207Z-debug-0.log

Log:

110 timing auditReport:init Completed in 105ms
111 timing reify:audit Completed in 671ms
112 timing reify Completed in 1344ms
113 timing command:install Completed in 1411ms
114 verbose stack Error: command failed
114 verbose stack     at ChildProcess.<anonymous> (/home/ms6rb/.nvm/versions/node/v19.0.0/lib/node_modules/dules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
114 verbose stack     at ChildProcess.emit (node:events:513:28)
114 verbose stack     at maybeClose (node:internal/child_process:1098:16)
114 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:304:5)
115 verbose pkgid [email protected]
116 verbose cwd /home/ms6rb/vault-ai
117 verbose Linux 5.15.90.1-microsoft-standard-WSL2
118 verbose node v19.0.0
119 verbose npm  v9.6.5
120 error code 127
121 error path /home/ms6rb/vault-ai
122 error command failed
123 error command sh -c source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server
124 verbose exit 127
125 timing npm Completed in 1560ms
126 verbose code 127
127 error A complete log of this run can be found in: /home/ms6rb/.npm/_logs/2023-04-22T10_52_12_207Z-debug-debug-0.log
@marcocarrero
Copy link

Same Issue, i tried on windows, and ubuntu, no working

@tjb4578
Copy link

tjb4578 commented Apr 22, 2023

Try changing the npm scripts in package.json according to the following comment:

#7 (comment)

@ms6rb
Copy link
Author

ms6rb commented Apr 22, 2023

Try changing the npm scripts in package.json according to the following comment:

#7 (comment)

it worked regarding the installation of the packages. but when I try npm start nothing happened and I got this:

npm start

> [email protected] start
> bash -c 'source ./scripts/source-me.sh  && ./scripts/go-compile.sh ./vault-web-server'

=> Environment Variables Loaded
-> Installing './vault-web-server' dependencies
->  Compiling './vault-web-server'
   ... done

although npm run dev work fine.

@pashpashpash
Copy link
Owner

@ms6rb Those logs look good – the only difference is you want to run ./bin/vault-web-server after it compiles to start the server, and then go to your browser on http://localhost:8100/ to use the site locally

@pashpashpash
Copy link
Owner

pashpashpash commented Apr 24, 2023

@ms6rb try swapping out the top part of your source script to this:

#!/bin/bash
# Useful variables. Source from the root of the project

# Get the sourced script's directory in a more portable way
if [[ "${BASH_SOURCE[0]}" != /* ]]; then
  script_name="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
else
  script_name="${BASH_SOURCE[0]}"
fi
dir_path="$( cd "$(dirname "$script_name")" >/dev/null 2>&1 ; pwd -P )"

echo "DEBUG: dir_path = ${dir_path}"
secrets_path="${dir_path}/../secret"
echo "DEBUG: secrets_path = ${secrets_path}"
test ! -d $secrets_path && echo "ERR: ../secret dir missing!" && return 1

And then change your package.json "start" script like so:

 "start": "bash -c '. ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server'",

then try running npm start

@ms6rb
Copy link
Author

ms6rb commented Apr 27, 2023

I got this error:

> [email protected] start
> bash -c '. ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server'

DEBUG: dir_path = /home/xxx/vault-ai/scripts
DEBUG: secrets_path = /home/xxx/vault-ai/scripts/../secret

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

4 participants