我在一个使用 Docker 的 Laravel 8 项目中。实际上,我正在使用 SCSS 进行设计。
我的问题出现了,如果我尝试编译我的 SCSS。NPM 说,我的 Node 版本是 12.x 并且太旧了,但是在我的容器中,我使用的是 Node 版本 16.5。
我已经在命令行上使用以下命令进行了尝试:
./vendor/bin/sail npm run dev
./vendor/bin/sail npm run watch
它遇到了这个错误:
> @ watch /var/www/html
> mix watch
Error: You are using an unsupported version of Node. Please update to at least Node v12.14
at assertSupportedNodeVersion (/var/www/html/node_modules/laravel-mix/src/Engine.js:6:15)
at executeScript (/var/www/html/node_modules/laravel-mix/bin/cli.js:61:5)
at Command.program.command.description.option.option.action (/var/www/html/node_modules/laravel-mix/bin/cli.js:39:13)
at Command.listener [as _actionHandler] (/var/www/html/node_modules/commander/index.js:922:31)
at Command._parseCommand (/var/www/html/node_modules/commander/index.js:1503:14)
at Command._dispatchSubcommand (/var/www/html/node_modules/commander/index.js:1443:18)
at Command._parseCommand (/var/www/html/node_modules/commander/index.js:1460:12)
at Command.parse (/var/www/html/node_modules/commander/index.js:1292:10)
at Command.parseAsync (/var/www/html/node_modules/commander/index.js:1318:10)
at run (/var/www/html/node_modules/laravel-mix/bin/cli.js:50:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `mix watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sail/.npm/_logs/2021-08-28T08_08_14_074Z-debug.log
所以我已经进入我的容器docker exec -it <container-id> /bin/bash
。我在那里寻找我的实际 Node 版本node -v
。它说,节点版本 16.5 已经安装。
这是完整日志文件的内容:
root@c20f3997d228:/var/www/html# cat /home/sail/.npm/_logs/2021-08-28T08_09_07_299Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm@6.14.4
3 info using node@v10.19.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/html/node_modules/.bin:/root/.nvm/versions/node/v16.5/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle @~dev: CWD: /var/www/html
10 silly lifecycle @~dev: Args: [ '-c', 'npm run development' ]
11 silly lifecycle @~dev: Returned: code: 1 signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `npm run development`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid @
15 verbose cwd /var/www/html
16 verbose Linux 5.10.25-linuxkit
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
18 verbose node v10.19.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error @ dev: `npm run development`
22 error Exit status 1
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
有人知道为什么 NPM 说没有实际版本吗?
问候,曼尼