jsdecena / laracom

Laravel FREE E-Commerce Software
https://jsdecena.github.io/laracom
1.91k stars 861 forks source link

npm does install/compile on Apple Silicon? #268

Closed benjaminv closed 3 years ago

benjaminv commented 3 years ago

It seemed stuck in on installing admin-lte for a while then threw big amount of errors. reify:admin-lte: timing reifyNode:node_modules/rxjs Completed in 8908ms

log reads

...
8392 timing command:install Completed in 121550ms
8393 verbose stack Error: command failed
8393 verbose stack     at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
8393 verbose stack     at ChildProcess.emit (node:events:394:28)
8393 verbose stack     at maybeClose (node:internal/child_process:1067:16)
8393 verbose stack     at Socket.<anonymous> (node:internal/child_process:453:11)
8393 verbose stack     at Socket.emit (node:events:394:28)
8393 verbose stack     at Pipe.<anonymous> (node:net:661:12)
8394 verbose pkgid node-sass@4.14.1
8395 verbose cwd /Users/myproject_path/laracom
8396 verbose Darwin 20.4.0
8397 verbose argv "/opt/homebrew/Cellar/node/16.3.0/bin/node" "/opt/homebrew/bin/npm" "install"
8398 verbose node v16.3.0
8399 verbose npm  v7.15.1
8400 error code 1
8401 error path /Users/myproject_path/laracom/node_modules/node-sass
8402 error command failed
8403 error command sh -c node scripts/build.js
8404 error Building: /opt/homebrew/Cellar/node/16.3.0/bin/node /Users/myproject_path/laracom/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
8404 error   c++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.5.5"' -I/Users/benhu/.node-gyp/16.3.0/include/node -I/Users/benhu/.node-gyp/16.3.0/src -I/Users/benhu/.node-gyp/16.3.0/deps/openssl/config -I/Users/benhu/.node-gyp/16.3.0/deps/openssl/openssl/include -I/Users/benhu/.node-gyp/16.3.0/deps/uv/include -I/Users/benhu/.node-gyp/16.3.0/deps/zlib -I/Users/benhu/.node-gyp/16.3.0/deps/v8/include -I../src/libsass/include  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp
8404 error   c++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.5.5"' -I/Users/benhu/.node-gyp/16.3.0/include/node -I/Users/benhu/.node-gyp/16.3.0/src -I/Users/benhu/.node-gyp/16.3.0/deps/openssl/config -I/Users/benhu/.node-gyp/16.3.0/deps/openssl/openssl/include -I/Users/benhu/.node-gyp/16.3.0/deps/uv/include -I/Users/benhu/.node-gyp/16.3.0/deps/zlib -I/Users/benhu/.node-gyp/16.3.0/deps/v8/include -I../src/libsass/include  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast_fwd_decl.o.d.raw   -c -o Release/obj.target/libsass/src/libsass/src/ast_fwd_decl.o ../src/libsass/src/ast_fwd_decl.cpp

...

I am using Big Sur on a MBA 2020 M1. Any comment will be appreciated.

jsdecena commented 3 years ago

Can you show me the steps so I can replicate it?

benjaminv commented 3 years ago

Can you show me the steps so I can replicate it?

Thanks for following up @jsdecena. I am running on a local dev environment. PHP 7.4.12 (cli) (built: Nov 30 2020 13:28:43) ( NTS ) MYSQL 5.7.32 - MySQL Community Server (GPL) Node --version 16.5 NPM --version 7.19.1

The server stack is working well - how do I know this? I terminated the npm install process with a residual node_modules folder, then built with npm run dev, everything runs okay.

Please follow these to replicate:

Step 1: Get the current git code

% git clone git@github.com:jsdecena/laracom.git 

Step 2: Move the laravel project to root folder

% cd laracom
% mv project/* ~/MY_PROJECT_PATH/laracom
% rm .github nginx/* php/* project/* .travis.yml Dockfile  docker-compose.yml

Step 3: Composer install components

% composer install
# completed without issue

Step 4: Database .env config

Step 5: Data seeding

% php artisan migrate --seed
% php artisan storage:link

Step 6: Frontend compiling

% npm install
# runs into error as shown in above
Troubleshooting

which included,

Break npm install with a residual node_modules folder

Without a break (Ctrl + C), the dependencies' installation rolls back and node_modules folder is removed automatically.

run npm run dev I did have got the built successfully for once - tried replication without success

Serve and run

% php artisan serve

Things worked okay this way but apparently there were something not correctly built during the npm install. Appreciate your time.

benjaminv commented 3 years ago

@jsdecena Hi I now have figured out that the hanging of Terminal for a few minutes as well running into error were due to incompatibility between newer version of node again node-sass. I did have tried forcing the node-sass to be version ^6.0 and that did not work for me. My final solution was to downgrade my brew/node from ver 16 down to LTS ver 14 - I was mis-led by node-sass's official announcement of compatibility to node@16, which did not work in this case. For anyone did not know how to down grade node, this is the brew way on Apple Silicon - https://github.com/npm/cli/issues/2306#issuecomment-882215868

benjaminv commented 3 years ago

this is now closed as I have found the cause and fix.