Closed trusktr closed 1 year ago
That doesn’t look like surge’s script, it looks like your own.
@ljharb Yeah, it's my own script of a package of mine, but I didn't think it would run if I passed --ignore-scripts
.
I'm running npm i surge -D --ignore-scripts
inside of home/trusktr/src/lume+lume
, and home/trusktr/src/lume+lume/packages/element-behaviors
is a package that I manage with Lerna.
I don't have an install
script in the root of the repo. I have prepare
, and build
, but neither of those call lerna
, so I'm not sure why a script from packages/element-behaviors
is being executed.
One thing is that home/trusktr/src/lume+lume/node_modules/element-behaviors
at the root of the repo is a symlink to home/trusktr/src/lume+lume/packages/element-behaviors
. Could that have anything to do with it (doesn't seem like it would, but that's the only way that the package is connected to the root of the repo as far as I know.
The flag ignores install scripts of what you’re installing. It then has to run your project’s scripts, so it can potentially recompile with new dependencies.
I can’t speak to the specific scripts or why they’re run; I’m only speaking to the expectation.
Yeah, that's the weird thing. According to https://docs.npmjs.com/cli/v8/using-npm/scripts#npm-install, it will run these scripts:
preinstall
install
postinstall
prepublish
preprepare
prepare
postprepare
I ensured I have none of those in the top level of the repo where package.json is. Then when I run npm i surge -D --ignore-scripts
, for some reason build
of a package in packages
runs.
I just tried npm i --ignore-scripts
, which does the same.
I should make a reproduction.
Check out this output that confirms what I'm seeing. The first command includes "dev"
to show that there is a "dev"
script, but that's not something npm install
runs, and all other scripts are missing:
lume+lume git:develop ❯ pwd
/home/trusktr/src/lume+lume
lume+lume git:develop ❯ cat package.json | grep -E '"dev"|"preinstall"|"install"|"postinstall"|"prepublish"|"preprepare"|"prepare"|"postprepare"'
"dev": "lume dev",
lume+lume git:develop ❯ npm i surge -D --ignore-scripts
npm ERR! code 2
npm ERR! path /home/trusktr/src/lume+lume/packages/element-behaviors
npm ERR! command failed
npm ERR! command sh -c npm run build
npm ERR! > element-behaviors@2.2.11 build
npm ERR! > lume build
npm ERR!
npm ERR!
npm ERR!
npm ERR! element-behaviors
npm ERR! * * * **** *
npm ERR! * * * * **
npm ERR! * * *
npm ERR! *
npm ERR! * *
npm ERR! * *
npm ERR! *
npm ERR! * * ** * *
npm ERR! *
npm ERR!
npm ERR! *
npm ERR! * *
npm ERR!
npm ERR!
npm ERR!
npm ERR!
npm ERR! [21:43:42] Using gulpfile ~/src/lume+lume/packages/element-behaviors/node_modules/@lume/cli/config/gulpfile.js
npm ERR! [21:43:42] Starting 'copyAssets'...
npm ERR! [21:43:42] Finished 'copyAssets' after 38 ms
npm ERR! src/index.ts:1:74 - error TS2307: Cannot find module '@lume/custom-attributes/dist/index.js' or its corresponding type declarations.
npm ERR!
npm ERR! 1 import {customAttributes, CustomAttributeRegistry, CustomAttribute} from '@lume/custom-attributes/dist/index.js'
npm ERR! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR!
npm ERR!
npm ERR! Found 1 error.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/trusktr/.npm/_logs/2021-12-31T05_43_32_455Z-debug-0.log
lume+lume git:develop ❯ ls -l /home/trusktr/.npm/_logs/2021-12-31T05_43_32_455Z-debug-0.log
ls: cannot access '/home/trusktr/.npm/_logs/2021-12-31T05_43_32_455Z-debug-0.log': No such file or directory
I would provide the debug log that it says it outputs, but that doesn't exist for some reason.
Added a reproduction to the OP.
It seems that this is due to some behavior in newer npm
that tries to re-build symlinked dependencies for some reason.
I discovered that running npm rebuild
causes the build
scripts of linked packages in node_modules
to be executed. Is this expected?
@ljharb Is npm rebuild
supposed to run build
of packages in node_modules
?
Yes.
And so --ignore-scripts
should in fact cause any build
script to be ignored, right?
I can't make a simple reproduction of what I experienced (trying with npm 10). My project has changed a lot by now too. I'll just close this.
I have the same problem... npm executes scripts despite passing ignore scripts
topkek@ayylmai UCRT64 ~/node/lol
$ npm install rollup/rollup#master --ignore-scripts
npm ERR! code 1
npm ERR! path C:\Users\topkek\AppData\Local\npm-cache\_cacache\tmp\git-cloneXXXXXXnAgC8C
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c husky && node scripts/check-release.js || npm run build:prepare
npm ERR! .git can't be found
npm ERR! > rollup@4.13.2 build:prepare
npm ERR! > concurrently -c green,blue "npm run build:napi -- --release" "npm:build:js:node" && npm run build:copy-native
npm ERR!
npm ERR! [build:js:node]
npm ERR! [build:js:node] > rollup@4.13.2 build:js:node
npm ERR! [build:js:node] > rollup --config rollup.config.ts --configPlugin typescript --configIsBuildNode --forceExit
npm ERR! [build:js:node]
npm ERR! [0]
npm ERR! [0] > rollup@4.13.2 build:napi
npm ERR! [0] > napi build --platform --dts native.d.ts --js false --cargo-cwd rust -p bindings_napi --cargo-name bindings_napi --release
npm ERR! [0]
npm ERR! [build:js:node] thread '<unnamed>' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\napi-sys-2.3.0\src\functions.rs:7:3:
npm ERR! [build:js:node] Must load N-API bindings
npm ERR! [build:js:node] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
npm ERR! [build:js:node] npm run build:js:node exited with code 3765269347
npm ERR! [0] Compiling proc-macro2 v1.0.79
npm ERR! [0] Compiling unicode-ident v1.0.12
npm ERR! [0] Compiling autocfg v1.2.0
npm ERR! [0] Compiling once_cell v1.19.0
npm ERR! [0] Compiling serde v1.0.197
npm ERR! [0] Compiling memchr v2.7.2
npm ERR! [0] Compiling version_check v0.9.4
npm ERR! [0] Compiling regex-syntax v0.8.3
npm ERR! [0] Compiling aho-corasick v1.1.3
npm ERR! [0] Compiling windows_x86_64_gnu v0.48.5
npm ERR! [0] Compiling quote v1.0.35
npm ERR! [0] Compiling syn v2.0.55
npm ERR! [0] Compiling cfg-if v1.0.0
npm ERR! [0] Compiling smallvec v1.13.2
npm ERR! [0] Compiling lock_api v0.4.11
npm ERR! [0] Compiling regex-automata v0.4.6
npm ERR! [0] Compiling rand_core v0.6.4
npm ERR! [0] Compiling parking_lot_core v0.9.9
npm ERR! [0] Compiling tinyvec_macros v0.1.1
npm ERR! [0] Compiling siphasher v0.3.11
npm ERR! [0] Compiling phf_shared v0.11.2
npm ERR! [0] Compiling tinyvec v1.6.0
npm ERR! [0] Compiling rand v0.8.5
npm ERR! [0] Compiling windows-targets v0.48.5
npm ERR! [0] Compiling scopeguard v1.2.0
npm ERR! [0] Compiling radium v0.7.0
npm ERR! [0] Compiling regex v1.10.4
npm ERR! [0] Compiling swc_macros_common v0.3.9
npm ERR! [0] Compiling unicode-normalization v0.1.23
npm ERR! [0] Compiling phf_generator v0.11.2
npm ERR! [0] Compiling ahash v0.8.11
npm ERR! [0] Compiling num-traits v0.2.18
npm ERR! [0] Compiling unicode-bidi v0.3.15
npm ERR! [0] Compiling percent-encoding v2.3.1
npm ERR! [0] Compiling rustc-hash v1.1.0
npm ERR! [0] Compiling tap v1.0.1
npm ERR! [0] Compiling lazy_static v1.4.0
npm ERR! [0] Compiling outref v0.1.0
npm ERR! [0] Compiling serde_json v1.0.115
npm ERR! [0] Compiling serde_derive v1.0.197
npm ERR! [0] Compiling phf_macros v0.11.2
npm ERR! [0] Compiling simd-abstraction v0.7.1
npm ERR! [0] Compiling idna v0.5.0
npm ERR! [0] Compiling Inflector v0.11.4
npm ERR! [0] Compiling wyz v0.5.1
npm ERR! [0] Compiling form_urlencoded v1.2.1
npm ERR! [0] Compiling getrandom v0.2.12
npm ERR! [0] Compiling uuid v1.8.0
npm ERR! [0] Compiling funty v2.0.0
npm ERR! [0] Compiling ryu v1.0.17
npm ERR! [0] Compiling itoa v1.0.11
npm ERR! [0] Compiling cc v1.0.90
npm ERR! [0] Compiling zerocopy v0.7.32
npm ERR! [0] Compiling bitvec v1.0.1
npm ERR! [0] Compiling url v2.5.0
npm ERR! [0] Compiling phf v0.11.2
npm ERR! [0] Compiling base64-simd v0.7.0
npm ERR! [0] Compiling tracing-attributes v0.1.27
npm ERR! [0] Compiling num-bigint v0.4.4
npm ERR! [0] Compiling tracing-core v0.1.32
npm ERR! [0] Compiling unicode-id-start v1.1.2
npm ERR! [0] Compiling pin-project-lite v0.2.13
npm ERR! [0] Compiling data-encoding v2.5.0
npm ERR! [0] Compiling debugid v0.8.0
npm ERR! [0] Compiling new_debug_unreachable v1.0.6
npm ERR! [0] Compiling if_chain v1.0.2
npm ERR! [0] Compiling hstr v0.2.7
npm ERR! [0] Compiling tracing v0.1.40
npm ERR! [0] Compiling num-integer v0.1.46
npm ERR! [0] Compiling sourcemap v8.0.0
npm ERR! [0] Compiling swc_visit_macros v0.5.11
npm ERR! [0] Compiling either v1.10.0
npm ERR! [0] Compiling scoped-tls v1.0.1
npm ERR! [0] Compiling better_scoped_tls v0.1.1
npm ERR! [0] Compiling swc_atoms v0.6.5
npm ERR! [0] Compiling from_variant v0.1.7
npm ERR! [0] Compiling ast_node v0.9.6
npm ERR! [0] Compiling swc_visit v0.5.10
npm ERR! [0] Compiling swc_eq_ignore_macros v0.1.3
npm ERR! [0] Compiling parking_lot v0.12.1
npm ERR! [0] Compiling unicode-width v0.1.11
npm ERR! [0] Compiling hashbrown v0.14.3
npm ERR! [0] Compiling swc_common v0.33.21
npm ERR! [0] Compiling bitflags v2.5.0
npm ERR! [0] Compiling is-macro v0.3.5
npm ERR! [0] Compiling string_enum v0.4.2
npm ERR! [0] Compiling unicode-id v0.3.4
npm ERR! [0] Compiling equivalent v1.0.1
npm ERR! [0] Compiling indexmap v2.2.6
npm ERR! [0] Compiling winapi-x86_64-pc-windows-gnu v0.4.0
npm ERR! [0] Compiling psm v0.1.21
npm ERR! [0] Compiling swc_ecma_ast v0.112.6
npm ERR! [0] Compiling winapi v0.3.9
npm ERR! [0] Compiling libc v0.2.153
npm ERR! [0] Compiling stacker v0.1.15
npm ERR! [0] Compiling smartstring v1.0.1
npm ERR! [0] Compiling swc_ecma_visit v0.98.7
npm ERR! [0] Compiling num_cpus v1.16.0
npm ERR! [0] Compiling static_assertions v1.1.0
npm ERR! [0] Compiling anyhow v1.0.81
npm ERR! [0] Compiling dashmap v5.5.3
npm ERR! [0] Compiling fixedbitset v0.4.2
npm ERR! [0] Compiling typed-arena v2.0.2
npm ERR! [0] Compiling windows_x86_64_gnu v0.52.4
npm ERR! [0] Compiling swc_ecma_parser v0.143.11
npm ERR! [0] Compiling petgraph v0.6.4
npm ERR! [0] Compiling swc_ecma_utils v0.127.15
npm ERR! [0] Compiling swc_cached v0.3.19
npm ERR! [0] Compiling swc_fast_graph v0.21.20
npm ERR! [0] Compiling swc_timer v0.21.21
npm ERR! [0] Compiling swc_ecma_transforms_macros v0.5.4
npm ERR! [0] Compiling swc_ecma_transforms_base v0.137.16
npm ERR! [0] Compiling swc_ecma_codegen_macros v0.7.4
npm ERR! [0] Compiling swc_config_macro v0.1.3
npm ERR! [0] Compiling semver v1.0.22
npm ERR! [0] Compiling swc_config v0.1.12
npm ERR! [0] Compiling swc_ecma_transforms_optimization v0.198.17
npm ERR! [0] Compiling swc_ecma_codegen v0.148.13
npm ERR! [0] Compiling swc_ecma_usage_analyzer v0.23.13
npm ERR! [0] Compiling windows-targets v0.52.4
npm ERR! [0] Compiling mimalloc-rust-sys v1.7.9-source
npm ERR! [0] Compiling unicode-segmentation v1.11.0
npm ERR! [0] Compiling ryu-js v1.0.1
npm ERR! [0] Compiling radix_fmt v1.0.0
npm ERR! [0] Compiling arrayvec v0.7.4
npm ERR! [0] Compiling swc_ecma_minifier v0.192.19
npm ERR! [0] Compiling convert_case v0.6.0
npm ERR! [0] Compiling libloading v0.8.3
npm ERR! [0] Compiling napi-build v2.1.2
npm ERR! [0] Compiling base64 v0.21.7
npm ERR! [0] Compiling cty v0.2.2
npm ERR! [0] Compiling pathdiff v0.2.1
npm ERR! [0] Compiling swc_compiler_base v0.7.19
npm ERR! [0] Compiling napi-derive-backend v1.0.63
npm ERR! [0] Compiling bindings_napi v0.0.0 (C:\Users\topkek\AppData\Local\npm-cache\_cacache\tmp\git-cloneXXXXXXnAgC8C\rust\bindings_napi)
npm ERR! [0] Compiling napi-sys v2.3.0
npm ERR! [0] Compiling ctor v0.2.7
npm ERR! [0] Compiling base-encode v0.3.1
npm ERR! [0] Compiling xxhash-rust v0.8.10
npm ERR! [0] Compiling napi v2.16.1
npm ERR! [0] Compiling xxhash v0.0.0 (C:\Users\topkek\AppData\Local\npm-cache\_cacache\tmp\git-cloneXXXXXXnAgC8C\rust\xxhash)
npm ERR! [0] Compiling napi-derive v2.16.1
npm ERR! [0] Compiling parse_ast v0.0.0 (C:\Users\topkek\AppData\Local\npm-cache\_cacache\tmp\git-cloneXXXXXXnAgC8C\rust\parse_ast)
npm ERR! [0] Compiling mimalloc-rust v0.2.1
npm ERR! [0] Finished release [optimized] target(s) in 2m 22s
npm ERR! [0] npm run build:napi -- --release exited with code 0
npm ERR! This script should only be run as part of the release process.
npm ERR! A complete log of this run can be found in: C:\Users\topkek\AppData\Local\npm-cache\_logs\2024-03-29T12_18_54_023Z-debug-0.log
The flag --ignore-scripts
does not ignore the prepare
script:
if ignore-scripts is set, but they will not run any pre- or post-scripts.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm i surge -D --ignore-scripts
runs scripts:Expected Behavior
It should not run scripts. In the above output, you see the
build
script of a package failed.Steps To Reproduce
Environment
globalignorefile = "/etc/npmignore" ; prefix = "/usr/local" ; overridden by user
; "user" config from /home/trusktr/.npmrc
//registry.npmjs.org/:_authToken = (protected) prefix = "/home/trusktr/.npm-packages"
; "project" config from /home/trusktr/src/lume+lume/.npmrc
engine-strict = true legacy-peer-deps = true package-lock = false
; node bin location = /home/trusktr/.n-node-versions/bin/node ; cwd = /home/trusktr/src/lume+lume ; HOME = /home/trusktr ; Run
npm config ls -l
to show all defaults.