AnomalyInnovations / serverless-nodejs-starter

A Node.js starter for Serverless Framework with ES6 and TypeScript support
https://serverless-stack.com/chapters/serverless-nodejs-starter.html
MIT License
755 stars 157 forks source link

gyp verb `which` failed Error: not found: python2 #73

Closed bedamatta05 closed 3 years ago

bedamatta05 commented 3 years ago

while running $ npm install in the repo, its throwing :

npm ERR! code 1
npm ERR! path C:\Users\saisw\my-project\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\saisw\my-project\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\saisw\\my-project\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',    
npm ERR! gyp verb cli   '--libsass_cflags=', 
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library=' 
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@15.5.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\saisw\my-project\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Users\saisw\AppData\Local\Programs\Python\Python39\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Users\saisw\AppData\Local\Programs\Python\Python39\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:333:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1063:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\saisw\\my-project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\saisw\my-project\node_modules\node-sass
npm ERR! gyp ERR! node -v v15.5.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

Error. Some please suggest me how to resolve this. Thank You.

jayair commented 3 years ago

It seems like a weird issue with a dependency. Can you try upgrading the version of serverless-bundle in your package.json to the latest? https://github.com/AnomalyInnovations/serverless-bundle/releases/tag/v4.3.0

Let me know if that works and we'll upgrade the repo with it.

bedamatta05 commented 3 years ago

Again its showing this error, seems like its not supporting the latest version of node and npm.

npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: 'concat-text-webpack-plugin@0.1.8', npm WARN EBADENGINE required: { node: '>=8 <=14' }, npm WARN EBADENGINE current: { node: 'v15.5.0', npm: '7.6.2' } npm WARN EBADENGINE } npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS: darwin npm ERR! notsup Valid Arch: undefined npm ERR! notsup Actual OS: win32 npm ERR! notsup Actual Arch: x64

jayair commented 3 years ago

This seems like a different package this time. Can you post the complete log?

bedamatta05 commented 3 years ago

Complete log :

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\saisw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'install'
0 verbose cli ]
1 info using npm@7.6.2
2 info using node@v15.5.0
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 4ms
5 timing config:load:builtin Completed in 5ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:C:\Users\saisw\notes-api\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\saisw\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\saisw\AppData\Roaming\npm\etc\npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 2ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 14ms
19 verbose npm-session 390efe50c1f28e51
20 timing npm:load Completed in 27ms
21 timing arborist:ctor Completed in 1ms
22 timing idealTree:init Completed in 548ms
23 timing idealTree:userRequests Completed in 0ms
24 silly idealTree buildDeps
25 timing idealTree:#root Completed in 0ms
26 timing idealTree:buildDeps Completed in 2ms
27 timing idealTree:fixDepFlags Completed in 0ms
28 warn EBADENGINE Unsupported engine {
28 warn EBADENGINE   package: 'concat-text-webpack-plugin@0.1.8',
28 warn EBADENGINE   required: { node: '>=8 <=14' },
28 warn EBADENGINE   current: { node: 'v15.5.0', npm: '7.6.2' }
28 warn EBADENGINE }
29 timing idealTree Completed in 565ms
30 timing command:install Completed in 574ms
31 verbose stack Error: Unsupported platform
31 verbose stack     at checkPlatform (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\npm-install-checks\index.js:35:25)
31 verbose stack     at Arborist.[checkPlatform] (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:235:5)
31 verbose stack     at C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:228:33
31 verbose stack     at async Arborist.buildIdealTree (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:212:7)
31 verbose stack     at async Promise.all (index 1)
31 verbose stack     at async Arborist.reify (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
31 verbose stack     at async Install.install (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\lib\install.js:120:5)
32 verbose pkgid fsevents@2.1.3
33 verbose cwd C:\Users\saisw\notes-api
34 verbose Windows_NT 10.0.19042
35 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\saisw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
36 verbose node v15.5.0
37 verbose npm  v7.6.2
38 error code EBADPLATFORM
39 error notsup Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
40 error notsup Valid OS:    darwin
40 error notsup Valid Arch:  undefined
40 error notsup Actual OS:   win32
40 error notsup Actual Arch: x64
41 verbose exit 1
jayair commented 3 years ago

Looks like it is Node 15 related for that specific package. We'll need to push an update for serverless-bundle for this.

jayair commented 3 years ago

Also, can you remove your package lock file and try installing it again? That package has a patch version that should fix this.

jayair commented 3 years ago

Just pushed a new version, https://github.com/AnomalyInnovations/serverless-bundle/releases/tag/v4.3.1.

I'm going to update this repo.

bedamatta05 commented 3 years ago

I have removed the package lock file and compiled npm install --save-dev --save-exact serverless-bundle@4.3.1 and this throws the following error.

npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS: darwin npm ERR! notsup Valid Arch: undefined npm ERR! notsup Actual OS: win32 npm ERR! notsup Actual Arch: x64

Complete log -

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\saisw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'install',
0 verbose cli   '--save-dev',
0 verbose cli   '--save-exact',
0 verbose cli   'serverless-bundle@4.3.1'
0 verbose cli ]
1 info using npm@7.6.2
2 info using node@v15.5.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 3ms
5 timing config:load:builtin Completed in 4ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:C:\Users\saisw\notes-api\.npmrc Completed in 1ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\saisw\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\saisw\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 13ms
19 verbose npm-session 7a96d3d291ee33a1
20 timing npm:load Completed in 24ms
21 timing arborist:ctor Completed in 0ms
22 timing arborist:ctor Completed in 0ms
23 timing arborist:ctor Completed in 0ms
24 timing arborist:ctor Completed in 0ms
25 timing idealTree:init Completed in 1086ms
26 timing idealTree:userRequests Completed in 1ms
27 silly idealTree buildDeps
28 silly fetch manifest serverless-bundle@4.3.1
29 http fetch GET 200 https://registry.npmjs.org/serverless-bundle 16ms (from cache)
30 silly placeDep ROOT serverless-bundle@4.3.1 REPLACE for: notes-api@2.2.0 want: 4.3.1
31 silly fetch manifest concat-text-webpack-plugin@^0.1.10
32 http fetch GET 200 https://registry.npmjs.org/concat-text-webpack-plugin 3ms (from cache)
33 timing idealTree:#root Completed in 35ms
34 silly placeDep ROOT concat-text-webpack-plugin@0.1.10 OK for: serverless-bundle@4.3.1 want: ^0.1.10
35 silly fetch manifest concat@1.0.3
36 http fetch GET 304 https://registry.npmjs.org/concat 752ms (from cache)
37 timing idealTree:node_modules/serverless-bundle Completed in 756ms
38 silly placeDep ROOT concat@1.0.3 OK for: concat-text-webpack-plugin@0.1.10 want: 1.0.3
39 timing idealTree:node_modules/concat-text-webpack-plugin Completed in 1ms
40 timing idealTree:node_modules/concat Completed in 0ms
41 timing idealTree:buildDeps Completed in 795ms
42 timing idealTree:fixDepFlags Completed in 13ms
43 timing idealTree Completed in 1904ms
44 timing command:install Completed in 1914ms
45 verbose stack Error: Unsupported platform
45 verbose stack     at checkPlatform (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\npm-install-checks\index.js:35:25)
45 verbose stack     at Arborist.[checkPlatform] (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:235:5)
45 verbose stack     at C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:228:33
45 verbose stack     at async Arborist.buildIdealTree (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:212:7)
45 verbose stack     at async Promise.all (index 1)
45 verbose stack     at async Arborist.reify (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
45 verbose stack     at async Install.install (C:\Users\saisw\AppData\Roaming\npm\node_modules\npm\lib\install.js:120:5)
46 verbose pkgid fsevents@2.1.3
47 verbose cwd C:\Users\saisw\notes-api
48 verbose Windows_NT 10.0.19042
49 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\saisw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "--save-exact" "serverless-bundle@4.3.1"
50 verbose node v15.5.0
51 verbose npm  v7.6.2
52 error code EBADPLATFORM
53 error notsup Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
54 error notsup Valid OS:    darwin
54 error notsup Valid Arch:  undefined
54 error notsup Actual OS:   win32
54 error notsup Actual Arch: x64
55 verbose exit 1
bedamatta05 commented 3 years ago

And please confirm which is the latest version repo, notes-api or notes-app-api or my-project ?

jayair commented 3 years ago

I don't think we've had Windows users with this error before. I wonder if it's related to npm 7 that you are using.

From looking around, setting fsevents as optional seems to fix this. https://stackoverflow.com/a/58178041/3369702

And please confirm which is the latest version repo, notes-api or notes-app-api or my-project ?

Not sure what you mean here. This repo is a starter that we use in our guides. So it depends on which guide you are following.

bedamatta05 commented 3 years ago

I installed node v14.17.0, and use the command npm install --save-dev --save-exact serverless-bundle@4.3.1 and after this compiled npm install -f .. Now the path problem is solved. Thank you

But now I'm getting another problem at https://serverless-stack.com/chapters/add-a-create-note-api.html , while compiling serverless invoke local --function create --path mocks/create-event.json . Instead of { "statusCode": 200, "body": "{\"userId\":\"123\",\"noteId\":\"bf586970-1007-11eb-a17f-a5105a0818d3\",\"content\":\"hello world\",\"attachment\":\"hello.jpg\",\"createdAt\":1602891102599}" }

it's throwing an error : `Serverless: DOTENV: Could not find .env file. Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:

I have completed all the steps accordingly and now unable to fetch. Please help.

jayair commented 3 years ago

It's a 500 error, follow the steps in the chapter https://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues

bedamatta05 commented 3 years ago

While completing the module (https://serverless-stack.com/chapters/add-a-create-note-api.html) i've changed the region to ap-south-1 and while compiling serverless invoke local --function create --path mocks/create-event.json , it throws the following error.

code: 'ResourceNotFoundException',
  time: 2021-05-16T17:42:30.967Z,
  requestId: 'EEKOS440F287JA88MTUCH94143VV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 400,
  retryable: false,
  retryDelay: 39.563195324762404
}
{
    "statusCode": 500,
    "body": "{\"error\":\"Requested resource not found\"}"
}

please check. but it works fine for the us-east-1.

jayair commented 3 years ago

Post these over on the forums for the relevant chapter discussion thread — https://discourse.serverless-stack.com

bedamatta05 commented 3 years ago

In the chapter https://serverless-stack.com/chapters/test-the-apis.html, while deploying npx aws-api-gateway-cli-test --username admin@example.com --password Passw0rd! --user-pool-id ap-south-1_HPhxRXhCE --app-client-id 7prrbnh2qb7qqckijv56k5qpq --cognito-region ap-south-1 --identity-pool-id ap-south-1:4035b314-5e28-4226-b176-84e0e781772e --invoke-url https://wx592asuj5.execute-api.ap-south-1.amazonaws.com/prod/notes --api-gateway-region ap-south-1 --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"

its throwing an error

Authenticating with User Pool
Getting temporary credentials
Making API request
undefined:1
{\\
 ^

SyntaxError: Unexpected token \ in JSON at position 1
    at JSON.parse (<anonymous>)
    at makeRequest (C:\Users\saisw\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-api-gateway-cli-test\index.js:179:17)
    at C:\Users\saisw\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-api-gateway-cli-test\index.js:152:5
    at C:\Users\saisw\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-sdk\lib\credentials.js:124:23
    at C:\Users\saisw\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-sdk\lib\credentials.js:212:15
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

please help in solving

Edit : As referred here https://github.com/AnomalyInnovations/serverless-stack-com/issues/112#issuecomment-748690654 , i also tried to fix this by running in both powershell and cmd promt but it's not working for me. :((

jayair commented 3 years ago

Have you tried figuring out if the problem is with the format of the --body param?

I'm going to close this issue since this isn't related to the original gyp issue. Posting this in the forums for the relevant chapter would work better.